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