diff --git a/client/core/src/multi-check/multi-check.spec.js b/client/core/src/multi-check/multi-check.spec.js index 7b81ef1e3..337cf1ac4 100644 --- a/client/core/src/multi-check/multi-check.spec.js +++ b/client/core/src/multi-check/multi-check.spec.js @@ -85,7 +85,7 @@ describe('Component vnMultiCheck', () => { expect(controller._models[1].checked).toBeTruthy(); }); - describe('when id is all or any', () => { + describe('when id is any', () => { it('should set element checked property based on controller._checkAll', () => { let controller = $componentController('vnMultiCheck', {}); controller.type = {id: 'any'}; @@ -108,5 +108,63 @@ describe('Component vnMultiCheck', () => { expect(controller._models[0].checked).toBeFalsy(); }); }); + + describe('when id is all', () => { + it('should set element checked property based on controller._checkAll property', () => { + let controller = $componentController('vnMultiCheck', {}); + controller.type = {id: 'all'}; + controller.models = [ + {name: 'name'} + ]; + + expect(controller._models[0].checked).not.toBeDefined(); + controller._checkAll = 1; + controller.switchChecks(); + + expect(controller._models[0].checked).toBeTruthy(); + controller._checkAll = 0; + controller.switchChecks(); + + expect(controller._models[0].checked).toBeFalsy(); + controller._checkAll = 2; + controller.switchChecks(); + + expect(controller._models[0].checked).toBeFalsy(); + }); + }); + }); + + describe('$onChanges()', () => { + it('should set controller.type to empty object and checkAll to zero', () => { + let controller = $componentController('vnMultiCheck', {}); + controller.type = {id: 'all'}; + controller._checkAll = 1; + controller.$onChanges(); + + expect(controller.type).toEqual({}); + expect(controller._checkAll).toEqual(0); + }); + }); + + describe('$doCheck()', () => { + it('should set controller.type to empty object and checkAll based on controller.type.id', () => { + let controller = $componentController('vnMultiCheck', {}); + controller.type = {id: 'all'}; + controller._checkAll = 0; + controller.$doCheck(); + + expect(controller.type).toEqual({}); + expect(controller._checkAll).toEqual(1); + controller.type = {id: 'any'}; + controller.$doCheck(); + + expect(controller.type).toEqual({}); + expect(controller._checkAll).toEqual(0); + controller.type = {id: 'any other id name'}; + controller.$doCheck(); + + expect(controller.type).toEqual({}); + expect(controller._checkAll).toEqual(2); + }); }); });