2018-08-07 15:07:41 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Order', () => {
|
|
|
|
describe('Component vnOrderVolume', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $scope;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('order'));
|
2018-08-07 15:07:41 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, $state, _$httpBackend_, $rootScope) => {
|
2018-08-07 15:07:41 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2020-04-28 12:26:02 +00:00
|
|
|
$scope.model = {
|
|
|
|
data: [
|
|
|
|
{itemFk: 1},
|
|
|
|
{itemFk: 2}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2018-08-07 15:07:41 +00:00
|
|
|
$state.params.id = 1;
|
2020-03-17 14:18:02 +00:00
|
|
|
const $element = angular.element('<vn-order-volume></vn-order-volume>');
|
|
|
|
controller = $componentController('vnOrderVolume', {$element, $scope});
|
2018-08-07 15:07:41 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('should join the sale volumes to its respective sale', () => {
|
2020-04-28 12:26:02 +00:00
|
|
|
let response = {
|
|
|
|
volumes: [
|
|
|
|
{itemFk: 1, volume: 0.008},
|
|
|
|
{itemFk: 2, volume: 0.003}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
$httpBackend.expectGET(`Orders/1/getVolumes`).respond(response);
|
2018-08-07 15:07:41 +00:00
|
|
|
controller.onDataChange();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-03-17 14:18:02 +00:00
|
|
|
expect(controller.$.model.data[0].volume).toBe(0.008);
|
|
|
|
expect(controller.$.model.data[1].volume).toBe(0.003);
|
2018-08-07 15:07:41 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|