2019-11-25 07:35:34 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('component vnZoneSummary', () => {
|
|
|
|
let $element;
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $httpParamSerializer;
|
|
|
|
|
2020-02-25 07:08:13 +00:00
|
|
|
beforeEach(ngModule('zone'));
|
2019-11-25 07:35:34 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$httpParamSerializer = _$httpParamSerializer_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$element = angular.element(`<vn-zone-summary></vn-zone-summary>`);
|
|
|
|
controller = $componentController('vnZoneSummary', {$element, $scope});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('zone setter', () => {
|
|
|
|
it('should set the zone and then call both getSummary() and getWarehouses()', () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller, 'getSummary');
|
|
|
|
jest.spyOn(controller, 'getWarehouses');
|
2019-11-25 07:35:34 +00:00
|
|
|
|
|
|
|
controller.zone = {id: 1};
|
|
|
|
|
|
|
|
expect(controller.getSummary).toHaveBeenCalledWith();
|
|
|
|
expect(controller.getWarehouses).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getSummary()', () => {
|
|
|
|
it('should perform a get and then store data on the controller', () => {
|
|
|
|
controller._zone = {id: 1};
|
|
|
|
let params = {
|
|
|
|
filter: {
|
|
|
|
include: {
|
|
|
|
relation: 'agencyMode',
|
|
|
|
fields: ['name']
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
id: controller._zone.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const serializedParams = $httpParamSerializer(params);
|
|
|
|
const query = `Zones/findOne?${serializedParams}`;
|
|
|
|
$httpBackend.expectGET(query).respond({id: 1});
|
|
|
|
controller.getSummary();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.summary).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
xdescribe('getEntries()', () => {
|
|
|
|
it('should call the getEntries method to get the entries data', () => {
|
|
|
|
controller._travel = {id: 999};
|
|
|
|
|
|
|
|
const query = `/api/Travels/${controller._travel.id}/getEntries`;
|
|
|
|
$httpBackend.expectGET(query).respond('I am the entries');
|
|
|
|
controller.getEntries();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.entries).toEqual('I am the entries');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|