2017-10-13 14:26:47 +00:00
|
|
|
import './multi-check.js';
|
|
|
|
|
2018-09-06 14:38:49 +00:00
|
|
|
describe('Component vnMultiCheck', () => {
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2018-09-06 14:38:49 +00:00
|
|
|
let $element;
|
2017-10-13 14:26:47 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2017-10-13 14:26:47 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
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});
|
2017-10-13 14:26:47 +00:00
|
|
|
}));
|
|
|
|
|
2018-05-08 09:45:22 +00:00
|
|
|
describe('checkAll() setter', () => {
|
2017-10-13 14:26:47 +00:00
|
|
|
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`, () => {
|
2018-05-08 09:45:22 +00:00
|
|
|
controller.data = [
|
2017-10-13 14:26:47 +00:00
|
|
|
{name: 'name'},
|
|
|
|
{name: null}
|
|
|
|
];
|
|
|
|
|
2018-05-08 09:45:22 +00:00
|
|
|
expect(controller.data[0].checked).not.toBeDefined();
|
|
|
|
expect(controller.data[1].checked).not.toBeDefined();
|
2017-10-13 14:26:47 +00:00
|
|
|
controller._checkAll = 1;
|
|
|
|
controller.switchChecks();
|
|
|
|
|
2018-05-08 09:45:22 +00:00
|
|
|
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
|
|
|
});
|
2017-10-13 14:26:47 +00:00
|
|
|
});
|