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

65 lines
1.7 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
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
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 uncheck value and change to null when clicked`, () => {
$ctrl.field = false;
$ctrl.tripleState = true;
element.click();
2019-02-19 06:04:56 +00:00
expect($ctrl.field).toEqual(null);
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
});
});
});