Free and Open source Web Builder Framework. Next generation tool for building templates without coding
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1018 B

import PanelsView from '../../../../src/panels/view/PanelsView';
import Panels from '../../../../src/panels/model/Panels';
import Editor from '../../../../src/editor';
describe('PanelsView', () => {
let fixtures: HTMLElement;
let editor: Editor;
let model: Panels;
let view: PanelsView;
beforeEach(() => {
editor = new Editor({});
model = new Panels(editor.Panels, []);
view = new PanelsView(model);
document.body.innerHTML = '<div id="fixtures"></div>';
fixtures = document.body.querySelector('#fixtures')!;
fixtures.appendChild(view.render().el);
});
afterEach(() => {
view.collection.reset();
});
test('Collection is empty', () => {
expect(view.$el.html()).toEqual('');
});
test('Add new panel', () => {
const spy = jest.spyOn(view, 'addToCollection' as any);
view.collection.add([{}]);
expect(spy).toBeCalledTimes(1);
});
test('Render new panel', () => {
view.collection.add([{}]);
expect(view.$el.html()).toBeTruthy();
});
});