#236 client side unit test for ticket volumes
This commit is contained in:
parent
3e8b26c91e
commit
03b2a75a84
|
@ -0,0 +1,40 @@
|
|||
import './ticket-volume';
|
||||
|
||||
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_;
|
||||
$scope = $rootScope.$new();
|
||||
$scope.index = {model: {instances: [{id: 1}, {id: 2}]}, accept: () => {}};
|
||||
$state = _$state_;
|
||||
$state.params.id = 101;
|
||||
controller = $componentController('vnTicketVolume', {$scope: $scope}, {$httpBackend: $httpBackend}, {$state: $state});
|
||||
}));
|
||||
|
||||
describe('total()', () => {
|
||||
it('should return the sum from all componenets in each sale', () => {
|
||||
controller.ticket = {id: 1};
|
||||
let response = {volumes: [[{saleFk: 1, m3: 0.008}, {saleFk: 2, m3: 0.003}]]};
|
||||
$httpBackend.whenGET(`/api/tickets/1/getVolume`).respond(response);
|
||||
$httpBackend.expectGET(`/api/tickets/1/getVolume`);
|
||||
controller.setVolumes();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.index.model.instances[0].volume.m3).toBe(0.008);
|
||||
expect($scope.index.model.instances[1].volume.m3).toBe(0.003);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -45,8 +45,7 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue