describe('Component vnCheck', () => { let $element; let $ctrl; let element; beforeEach(angular.mock.module('vnCore', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(inject(($compile, $rootScope) => { $element = $compile(``)($rootScope); $ctrl = $element.controller('vnCheck'); element = $element[0]; })); afterEach(() => { $element.remove(); }); describe('field() setter', () => { it(`should set model value`, () => { $ctrl.field = true; expect($ctrl.field).toEqual(true); }); it(`should uncheck value and change to true when clicked`, () => { $ctrl.field = false; element.click(); expect($ctrl.field).toEqual(true); }); it(`should check value and change to false when clicked`, () => { $ctrl.field = true; element.click(); expect($ctrl.field).toEqual(false); }); it(`should check value and change to false when clicked`, () => { $ctrl.field = true; $ctrl.tripleState = true; element.click(); expect($ctrl.field).toEqual(false); }); it(`should set value to null and change to true when clicked`, () => { $ctrl.field = null; $ctrl.tripleState = true; element.click(); expect($ctrl.field).toEqual(true); }); it(`should cast value to boolean when clicked`, () => { $ctrl.field = 0; element.click(); expect($ctrl.field).toEqual(true); }); }); });