2017-10-13 14:26:47 +00:00
|
|
|
import './multi-check.js';
|
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
xdescribe('Component vnMultiCheck', () => {
|
2017-10-13 14:26:47 +00:00
|
|
|
let $componentController;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2017-10-13 14:26:47 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('client');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(_$componentController_ => {
|
|
|
|
$componentController = _$componentController_;
|
2017-10-17 12:24:40 +00:00
|
|
|
controller = $componentController('vnMultiCheck', {});
|
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()', () => {
|
2017-10-20 08:42:55 +00:00
|
|
|
it(`should set checked property inside each existing elemenet when id begings with no-`, () => {
|
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
|
|
|
});
|