salix/front/core/components/multi-check/multi-check.spec.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

import './multi-check.js';
2018-09-06 14:38:49 +00:00
describe('Component vnMultiCheck', () => {
let controller;
2018-09-06 14:38:49 +00:00
let $element;
beforeEach(ngModule('vnCore'));
beforeEach(angular.mock.inject($componentController => {
2018-09-06 14:38:49 +00:00
$element = angular.element(`<div class="shown"></div>`);
controller = $componentController('vnMultiCheck', {$element: $element});
}));
describe('checkAll() setter', () => {
it(`should set controller _checkAll property with the argument received then call switchChecks()`, () => {
let argument = 'I am the model';
spyOn(controller, 'switchChecks');
controller.checkAll = argument;
expect(controller._checkAll).toEqual(argument);
expect(controller.switchChecks).toHaveBeenCalledWith();
});
});
describe('switchChecks()', () => {
2018-09-06 14:38:49 +00:00
it(`should set checked property inside each existing element`, () => {
controller.data = [
{name: 'name'},
{name: null}
];
expect(controller.data[0].checked).not.toBeDefined();
expect(controller.data[1].checked).not.toBeDefined();
controller._checkAll = 1;
controller.switchChecks();
expect(controller.data[0].checked).toBeTruthy();
expect(controller.data[1].checked).toBeTruthy();
2017-10-13 14:43:11 +00:00
});
2017-10-20 08:42:55 +00:00
});
});