Browse Source

Up panel/index to TS

pull/5196/head
Artur Arseniev 3 years ago
parent
commit
1749a58c02
  1. 2
      src/panels/index.ts
  2. 26
      test/specs/panels/index.ts

2
src/panels/index.ts

@ -79,7 +79,7 @@ export default class PanelManager extends Module<PanelsConfig> {
* buttons : [...], * buttons : [...],
* }); * });
*/ */
addPanel(panel: Panel | Array<Record<string, any>>) { addPanel(panel: Panel | Record<string, any>[]) {
return this.panels.add(panel); return this.panels.add(panel);
} }

26
test/specs/panels/index.js → test/specs/panels/index.ts

@ -1,6 +1,6 @@
import Panels from 'panels'; import Panels from '../../../src/panels';
import Panel from 'panels/model/Panel'; import Panel from '../../../src/panels/model/Panel';
import Editor from 'editor/model/Editor'; import Editor from '../../../src/editor/model/Editor';
describe('Panels', () => { describe('Panels', () => {
describe('Main', () => { describe('Main', () => {
@ -81,21 +81,21 @@ describe('Panels', () => {
}); });
test('Active correctly activable buttons', () => { test('Active correctly activable buttons', () => {
var spy = sinon.spy(); const fn = jest.fn();
var panel = obj.addPanel({ id: 'test' }); obj.addPanel({ id: 'test' });
var btn = obj.addButton('test', { id: 'btn', active: true }); const btn = obj.addButton('test', { id: 'btn', active: true });
btn.on('updateActive', spy); btn.on('updateActive', fn);
obj.active(); obj.active();
expect(spy.called).toEqual(true); expect(fn).toBeCalledTimes(1);
}); });
test('Disable correctly buttons flagged as disabled', () => { test('Disable correctly buttons flagged as disabled', () => {
var spy = sinon.spy(); const fn = jest.fn();
var panel = obj.addPanel({ id: 'test' }); obj.addPanel({ id: 'test' });
var btn = obj.addButton('test', { id: 'btn', disable: true }); const btn = obj.addButton('test', { id: 'btn', disable: true });
btn.on('change:disable', spy); btn.on('change:disable', fn);
obj.disableButtons(); obj.disableButtons();
expect(spy.called).toEqual(true); expect(fn).toBeCalledTimes(1);
}); });
test("Can't remove button to non existent panel", () => { test("Can't remove button to non existent panel", () => {
Loading…
Cancel
Save