2018-05-25 08:03:45 +00:00
|
|
|
import './index';
|
2018-04-16 14:47:04 +00:00
|
|
|
|
|
|
|
describe('ticket', () => {
|
|
|
|
describe('Component vnTicketVolume', () => {
|
|
|
|
let $componentController;
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $state;
|
|
|
|
let $scope;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('ticket');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_, $rootScope) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
2018-05-25 15:25:35 +00:00
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
2018-04-16 14:47:04 +00:00
|
|
|
$scope = $rootScope.$new();
|
2018-07-17 06:44:31 +00:00
|
|
|
$scope.model = {data: [{id: 1}, {id: 2}], accept: () => {
|
2018-04-30 11:57:10 +00:00
|
|
|
return {
|
|
|
|
then: () => {}
|
|
|
|
};
|
|
|
|
}};
|
2018-05-28 07:30:00 +00:00
|
|
|
$state = _$state_;
|
2018-04-16 14:47:04 +00:00
|
|
|
$state.params.id = 101;
|
|
|
|
controller = $componentController('vnTicketVolume', {$scope: $scope}, {$httpBackend: $httpBackend}, {$state: $state});
|
|
|
|
}));
|
|
|
|
|
2018-04-16 15:13:58 +00:00
|
|
|
it('should join the sale volumes to its respective sale', () => {
|
|
|
|
controller.ticket = {id: 1};
|
2018-05-28 07:30:00 +00:00
|
|
|
let response = {volumes: [{saleFk: 1, m3: 0.008}, {saleFk: 2, m3: 0.003}]};
|
2018-04-16 15:13:58 +00:00
|
|
|
$httpBackend.whenGET(`/api/tickets/1/getVolume`).respond(response);
|
|
|
|
$httpBackend.expectGET(`/api/tickets/1/getVolume`);
|
2018-07-17 06:44:31 +00:00
|
|
|
controller.onDataChange();
|
2018-04-16 15:13:58 +00:00
|
|
|
$httpBackend.flush();
|
2018-04-16 14:47:04 +00:00
|
|
|
|
2018-07-17 06:44:31 +00:00
|
|
|
expect($scope.model.data[0].volume.m3).toBe(0.008);
|
|
|
|
expect($scope.model.data[1].volume.m3).toBe(0.003);
|
2018-04-16 14:47:04 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|