42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import './multi-check.js';
|
|
|
|
describe('Component vnMultiCheck', () => {
|
|
let controller;
|
|
let $element;
|
|
|
|
beforeEach(ngModule('vnCore'));
|
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
|
$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()', () => {
|
|
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();
|
|
});
|
|
});
|
|
});
|