Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
0c84722755
|
@ -0,0 +1,68 @@
|
|||
import './column-header.js';
|
||||
|
||||
describe('Component vnColumnHeader', () => {
|
||||
let $componentController;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(_$componentController_ => {
|
||||
$componentController = _$componentController_;
|
||||
}));
|
||||
|
||||
describe('onClick()', () => {
|
||||
it(`should change the ordenation to DESC (descendant) if it was ASC (ascendant)`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {selectColum: () => {}}});
|
||||
controller.order = 'ASC';
|
||||
controller.onClick();
|
||||
|
||||
expect(controller.order).toEqual('DESC');
|
||||
});
|
||||
|
||||
it(`should change the ordenation to ASC (ascendant) if it wasnt ASC`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {selectColum: () => {}}});
|
||||
controller.order = 'DESC or any other value that might occur';
|
||||
controller.onClick();
|
||||
|
||||
expect(controller.order).toEqual('ASC');
|
||||
});
|
||||
|
||||
it(`should call the selectColum() function after changing a value`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {selectColum: () => {}}});
|
||||
controller.order = 'Change me!';
|
||||
spyOn(controller.gridHeader, 'selectColum');
|
||||
controller.onClick();
|
||||
|
||||
expect(controller.gridHeader.selectColum).toHaveBeenCalledWith(controller);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showArrow()', () => {
|
||||
it(`should return true when the type is DESC and MouseIsOver`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {selectColum: () => {}}});
|
||||
controller.mouseIsOver = true;
|
||||
let result = controller.showArrow('DESC');
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should return true if many conditions are true`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {currentColumn: {field: 'fields should be identical'}}});
|
||||
controller.field = 'fields should be identical';
|
||||
controller.order = 'ASC';
|
||||
let result = controller.showArrow('ASC');
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should return false without type being DESC or any other values being true`, () => {
|
||||
let controller = $componentController('vnColumnHeader', {}, {gridHeader: {currentColumn: {field: 'this field isnt the same as controllers field'}}});
|
||||
controller.field = 'I am the controllers field';
|
||||
controller.order = 'ASC';
|
||||
let result = controller.showArrow('ASC');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue