|
|
|
@ -21,18 +21,18 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('Adds new panel correctly via object', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('New panel has no buttons', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
expect(panel.buttons.length).toEqual(0); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Adds new panel correctly via Panel instance', () => { |
|
|
|
var oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
var panel = obj.addPanel(oPanel); |
|
|
|
const oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
const panel = obj.addPanel(oPanel); |
|
|
|
expect(panel).toEqual(oPanel); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
}); |
|
|
|
@ -42,7 +42,7 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('getPanel returns correctly the panel', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
expect(obj.getPanel('test')).toEqual(panel); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -51,8 +51,8 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('Add button correctly', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
var btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
expect(panel.buttons.length).toEqual(1); |
|
|
|
expect(panel.buttons.at(0).get('id')).toEqual('btn'); |
|
|
|
}); |
|
|
|
@ -62,13 +62,13 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('getButton returns null in case there is no requested button', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
obj.addPanel({ id: 'test' }); |
|
|
|
expect(obj.getButton('test', 'btn')).toEqual(null); |
|
|
|
}); |
|
|
|
|
|
|
|
test('getButton returns correctly the button', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
var btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
expect(obj.getButton('test', 'btn')).toEqual(btn); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -79,8 +79,8 @@ describe('Panels', () => { |
|
|
|
test('Active correctly activable buttons', () => { |
|
|
|
const fn = jest.fn(); |
|
|
|
obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn', active: true })!; |
|
|
|
btn.on('updateActive', fn); |
|
|
|
const btn = obj.addButton('test', { id: 'btn', active: true }); |
|
|
|
btn?.on('updateActive', fn); |
|
|
|
obj.active(); |
|
|
|
expect(fn).toBeCalledTimes(1); |
|
|
|
}); |
|
|
|
@ -88,8 +88,8 @@ describe('Panels', () => { |
|
|
|
test('Disable correctly buttons flagged as disabled', () => { |
|
|
|
const fn = jest.fn(); |
|
|
|
obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn', disable: true })!; |
|
|
|
btn.on('change:disable', fn); |
|
|
|
const btn = obj.addButton('test', { id: 'btn', disable: true }); |
|
|
|
btn?.on('change:disable', fn); |
|
|
|
obj.disableButtons(); |
|
|
|
expect(fn).toBeCalledTimes(1); |
|
|
|
}); |
|
|
|
@ -100,8 +100,8 @@ describe('Panels', () => { |
|
|
|
|
|
|
|
describe('Removes button', () => { |
|
|
|
test('Remove button correctly with object', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
var btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
expect(panel.buttons.length).toEqual(1); |
|
|
|
expect(panel.buttons.at(0).get('id')).toEqual('btn'); |
|
|
|
expect(obj.removeButton('test', { id: 'btn' })).toEqual(btn); |
|
|
|
@ -109,8 +109,8 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('Remove button correctly with sting', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
var btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
const btn = obj.addButton('test', { id: 'btn' }); |
|
|
|
expect(panel.buttons.length).toEqual(1); |
|
|
|
expect(panel.buttons.at(0).get('id')).toEqual('btn'); |
|
|
|
expect(obj.removeButton('test', 'btn')).toEqual(btn); |
|
|
|
@ -120,15 +120,15 @@ describe('Panels', () => { |
|
|
|
|
|
|
|
describe('Removes Panel', () => { |
|
|
|
test('Removes panel correctly via object', () => { |
|
|
|
var panel = obj.addPanel({ id: 'test' }); |
|
|
|
const panel = obj.addPanel({ id: 'test' }); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
obj.removePanel('test'); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Removes panel correctly via Panel instance', () => { |
|
|
|
var oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
var panel = obj.addPanel(oPanel); |
|
|
|
const oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
const panel = obj.addPanel(oPanel); |
|
|
|
expect(panel).toEqual(oPanel); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
obj.removePanel(oPanel); |
|
|
|
@ -136,8 +136,8 @@ describe('Panels', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('Removes panel correctly via id', () => { |
|
|
|
var oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
var panel = obj.addPanel(oPanel); |
|
|
|
const oPanel = new Panel(obj, { id: 'test' }); |
|
|
|
const panel = obj.addPanel(oPanel); |
|
|
|
expect(panel).toEqual(oPanel); |
|
|
|
expect(panel.get('id')).toEqual('test'); |
|
|
|
obj.removePanel('test'); |
|
|
|
|