Client side unit test for grid-header

This commit is contained in:
Carlos 2017-10-13 10:45:06 +02:00
parent 311d80d902
commit 7cf57d05f1
1 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,44 @@
import './grid-header.js';
describe('Component vnGridHeader', () => {
let $componentController;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
}));
describe('selectColum()', () => {
it(`should set controller currentColumn to equal the argument received`, () => {
let controller = $componentController('vnGridHeader', {});
let col = {columnStuff: 'some stuff'};
controller.selectColum(col);
expect(controller.currentColumn).toEqual(col);
});
it(`should set controller currentColumn.order to undefined then set currentColumn to equal the argument received`, () => {
let controller = $componentController('vnGridHeader', {});
controller.currentColumn = {field: 'some field', order: 'ordered'};
let col = {columnStuff: 'some stuff'};
controller.selectColum(col);
expect(controller.currentColumn.order).not.toBeDefined();
expect(controller.currentColumn).toEqual(col);
});
it(`should set controller currentColumn.order to undefined then call onOrder passing currentColumn as argument`, () => {
let controller = $componentController('vnGridHeader', {});
controller.onOrder = () => {};
spyOn(controller, 'onOrder');
let col = {columnStuff: 'some stuff'};
controller.selectColum(col);
expect(controller.currentColumn).toEqual(col);
expect(controller.onOrder).toHaveBeenCalledWith(col);
});
});
});