2020-08-25 08:22:57 +00:00
|
|
|
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', () => {
|
2020-08-25 12:10:38 +00:00
|
|
|
it('should return the checked lines', () => {
|
2020-08-25 08:22:57 +00:00
|
|
|
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', () => {
|
2020-08-25 12:10:38 +00:00
|
|
|
it('should return the total checked lines', () => {
|
2020-08-25 08:22:57 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|