Client side unit test for grid-header
This commit is contained in:
parent
311d80d902
commit
7cf57d05f1
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue