salix/client/core/src/components/multi-check/multi-check.spec.js

44 lines
1.4 KiB
JavaScript
Raw Normal View History

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