|
@@ -27,6 +27,12 @@ import {
|
|
|
class LogEditor extends CodeMirrorEditor {
|
|
|
|
|
|
methods: string[] = [];
|
|
|
+ events: string[] = [];
|
|
|
+
|
|
|
+ handleEvent(event: Event): void {
|
|
|
+ super.handleEvent(event);
|
|
|
+ this.events.push(event.type);
|
|
|
+ }
|
|
|
|
|
|
refresh(): void {
|
|
|
super.refresh();
|
|
@@ -43,12 +49,6 @@ class LogEditor extends CodeMirrorEditor {
|
|
|
class LogWidget extends CodeEditorWidget {
|
|
|
|
|
|
methods: string[] = [];
|
|
|
- events: string[] = [];
|
|
|
-
|
|
|
- handleEvent(event: Event): void {
|
|
|
- super.handleEvent(event);
|
|
|
- this.events.push(event.type);
|
|
|
- }
|
|
|
|
|
|
protected onActivateRequest(msg: Message): void {
|
|
|
super.onActivateRequest(msg);
|
|
@@ -100,6 +100,13 @@ describe('CodeEditorWidget', () => {
|
|
|
expect(widget).to.be.a(CodeEditorWidget);
|
|
|
});
|
|
|
|
|
|
+ it('should add a focus listener', () => {
|
|
|
+ widget.node.tabIndex = -1;
|
|
|
+ simulate(widget.node, 'focus');
|
|
|
+ let editor = widget.editor as LogEditor;
|
|
|
+ expect(editor.events).to.contain('focus');
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#editor', () => {
|
|
@@ -120,6 +127,17 @@ describe('CodeEditorWidget', () => {
|
|
|
expect(widget.isDisposed).to.be(true);
|
|
|
});
|
|
|
|
|
|
+ it('should remove the focus listener', () => {
|
|
|
+ let editor = widget.editor as LogEditor;
|
|
|
+ expect(editor.isDisposed).to.be(false);
|
|
|
+ widget.dispose();
|
|
|
+ expect(editor.isDisposed).to.be(true);
|
|
|
+
|
|
|
+ widget.node.tabIndex = -1;
|
|
|
+ simulate(widget.node, 'focus');
|
|
|
+ expect(editor.events).to.not.contain('focus');
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#handleEvent()', () => {
|
|
@@ -160,14 +178,6 @@ describe('CodeEditorWidget', () => {
|
|
|
|
|
|
describe('#onAfterAttach()', () => {
|
|
|
|
|
|
- it('should add a focus listener', () => {
|
|
|
- Widget.attach(widget, document.body);
|
|
|
- expect(widget.methods).to.contain('onAfterAttach');
|
|
|
- widget.node.tabIndex = -1;
|
|
|
- simulate(widget.node, 'focus');
|
|
|
- expect(widget.events).to.contain('focus');
|
|
|
- });
|
|
|
-
|
|
|
it('should refresh the editor', () => {
|
|
|
Widget.attach(widget, document.body);
|
|
|
let editor = widget.editor as LogEditor;
|
|
@@ -176,19 +186,6 @@ describe('CodeEditorWidget', () => {
|
|
|
|
|
|
});
|
|
|
|
|
|
- describe('#onBeforeDetach()', () => {
|
|
|
-
|
|
|
- it('should remove the focus listener', () => {
|
|
|
- Widget.attach(widget, document.body);
|
|
|
- Widget.detach(widget);
|
|
|
- expect(widget.methods).to.contain('onBeforeDetach');
|
|
|
- widget.node.tabIndex = -1;
|
|
|
- simulate(widget.node, 'focus');
|
|
|
- expect(widget.events).to.not.contain('focus');
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
describe('#onAfterShow()', () => {
|
|
|
|
|
|
it('should refresh the editor', () => {
|