checkbox front unit test
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
e85c346f45
commit
79e8c1b19a
|
@ -1,5 +1,5 @@
|
|||
<md-checkbox
|
||||
aria-label="{{::$ctrl.label}}"
|
||||
aria-label="::$ctrl.label"
|
||||
md-indeterminate="$ctrl.isIntermediate"
|
||||
ng-disabled="$ctrl.disabled"
|
||||
ng-checked="$ctrl.isChecked"
|
||||
|
|
|
@ -16,9 +16,7 @@ export default class Controller extends Component {
|
|||
set model(value) {
|
||||
if (value === null) return;
|
||||
|
||||
if (this.model === true)
|
||||
value = false;
|
||||
else if (this.model === false && this.tripleState)
|
||||
if (this.model === false && this.tripleState)
|
||||
value = null;
|
||||
|
||||
this.emit('change', {value});
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
fdescribe('Component vnCheck', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(ngModule('vnCore'));
|
||||
|
||||
beforeEach(inject(($compile, $rootScope) => {
|
||||
$element = $compile(`<vn-check></vn-check`)($rootScope);
|
||||
controller = $element.controller('vnCheck');
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
$element.remove();
|
||||
});
|
||||
|
||||
describe('model() setter', () => {
|
||||
it(`should set model value`, () => {
|
||||
controller.model = true;
|
||||
|
||||
expect(controller.model).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should set model value to null if current model value is false and is a triple-state checkbox`, () => {
|
||||
controller._model = false;
|
||||
controller.tripleState = true;
|
||||
controller.model = true;
|
||||
|
||||
expect(controller.model).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('field() setter', () => {
|
||||
it(`should set model value`, () => {
|
||||
controller.field = true;
|
||||
|
||||
expect(controller.field).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should set model value and convert numerical values to boolean values`, () => {
|
||||
controller.field = 1;
|
||||
|
||||
expect(controller.field).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isIntermediate() getter', () => {
|
||||
it(`should return true if intermediate property is truthy`, () => {
|
||||
controller.intermediate = true;
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should return true if is a triple-state checkbox and has null or undefined value`, () => {
|
||||
controller.tripleState = true;
|
||||
controller.model = null;
|
||||
|
||||
let result = controller.isIntermediate;
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -32,12 +32,12 @@ vn-treeview {
|
|||
background-color: $color-hover-cd
|
||||
}
|
||||
|
||||
li.expanded .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
li.expanded > vn-horizontal > .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
transition: all 0.2s;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
li.collapsed .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
li.collapsed > vn-horizontal > .actions > vn-icon[icon="keyboard_arrow_down"] {
|
||||
transition: all 0.2s;
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue