salix/front/core/components/check/index.spec.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-02-19 06:05:39 +00:00
describe('Component vnCheck', () => {
2019-02-19 06:04:56 +00:00
let $element;
let $ctrl;
let element;
2019-02-19 06:04:56 +00:00
beforeEach(ngModule('vnCore'));
2019-02-19 06:04:56 +00:00
beforeEach(inject(($compile, $rootScope) => {
$element = $compile(`<vn-check></vn-check>`)($rootScope);
$ctrl = $element.controller('vnCheck');
element = $element[0];
2019-02-19 06:04:56 +00:00
}));
afterEach(() => {
$element.remove();
});
describe('field() setter', () => {
2019-02-19 06:04:56 +00:00
it(`should set model value`, () => {
$ctrl.field = true;
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(true);
2019-02-19 06:04:56 +00:00
});
it(`should uncheck value and change to true when clicked`, () => {
$ctrl.field = false;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(true);
2019-02-19 06:04:56 +00:00
});
it(`should check value and change to false when clicked`, () => {
$ctrl.field = true;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(false);
2019-02-19 06:04:56 +00:00
});
it(`should check value and change to false when clicked`, () => {
$ctrl.field = true;
$ctrl.tripleState = true;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(false);
2019-02-19 06:04:56 +00:00
});
it(`should set value to null and change to true when clicked`, () => {
$ctrl.field = null;
$ctrl.tripleState = true;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(true);
2019-02-19 06:04:56 +00:00
});
it(`should cast value to boolean when clicked`, () => {
$ctrl.field = 0;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(true);
2019-02-19 06:04:56 +00:00
});
});
});