salix/modules/monitor/front/index/index.spec.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Component vnMonitorIndex', () => {
let controller;
let $element;
beforeEach(ngModule('monitor'));
beforeEach(inject(($compile, $rootScope) => {
$element = $compile('<vn-monitor-index></vn-monitor-index>')($rootScope);
controller = $element.controller('vnMonitorIndex');
}));
describe('toggle()', () => {
it('should add the hidden class to the horizontal contaning the panel to hide', () => {
controller.toggle();
const targetElement = $element[0].querySelector('vn-horizontal');
const firstClass = targetElement.classList[0];
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
expect(firstClass).toEqual('hidden');
expect(isTopPanelHidden).toEqual('true');
});
it('should remove the hidden class to the horizontal contaning the panel to hide', () => {
const targetElement = $element[0].querySelector('vn-horizontal');
targetElement.classList.add('hidden');
controller.toggle();
const firstClass = targetElement.classList[0];
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
expect(firstClass).toBeUndefined();
expect(isTopPanelHidden).toEqual('false');
});
});
});