Added unit test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
cd74e9684a
commit
17497c3f2d
|
@ -0,0 +1,60 @@
|
||||||
|
import './index.js';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
|
describe('Component vnRouteIndex', () => {
|
||||||
|
let controller;
|
||||||
|
|
||||||
|
beforeEach(ngModule('route'));
|
||||||
|
|
||||||
|
beforeEach(inject($componentController => {
|
||||||
|
const $element = angular.element('<vn-route-index></vn-route-index>');
|
||||||
|
controller = $componentController('vnRouteIndex', {$element});
|
||||||
|
controller.$.model = crudModel;
|
||||||
|
controller.$.model.data = [{id: 1}, {id: 2}, {id: 3}];
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('checked() getter', () => {
|
||||||
|
it('should should return the checked lines', () => {
|
||||||
|
const data = controller.$.model.data;
|
||||||
|
data[0].checked = true;
|
||||||
|
data[2].checked = true;
|
||||||
|
|
||||||
|
const checkedRows = controller.checked;
|
||||||
|
|
||||||
|
const firstCheckedRow = checkedRows[0];
|
||||||
|
const secondCheckedRow = checkedRows[1];
|
||||||
|
|
||||||
|
expect(firstCheckedRow.id).toEqual(1);
|
||||||
|
expect(secondCheckedRow.id).toEqual(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('totalCheked() getter', () => {
|
||||||
|
it('should should return the total checked lines', () => {
|
||||||
|
const data = controller.$.model.data;
|
||||||
|
data[0].checked = true;
|
||||||
|
|
||||||
|
const checkedRows = controller.totalChecked;
|
||||||
|
|
||||||
|
expect(checkedRows).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('showRouteReport()', () => {
|
||||||
|
it('should call to the vnReport show method', () => {
|
||||||
|
controller.vnReport.show = jest.fn();
|
||||||
|
|
||||||
|
const data = controller.$.model.data;
|
||||||
|
data[0].checked = true;
|
||||||
|
data[2].checked = true;
|
||||||
|
const expectedParams = {
|
||||||
|
authorization: null,
|
||||||
|
routeId: '1,3'
|
||||||
|
};
|
||||||
|
|
||||||
|
controller.showRouteReport();
|
||||||
|
|
||||||
|
expect(controller.vnReport.show).toHaveBeenCalledWith('driver-route', expectedParams);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue