43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import './index';
|
|
|
|
describe('Order', () => {
|
|
describe('Component vnOrderVolume', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
let $scope;
|
|
|
|
beforeEach(ngModule('order'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $state, _$httpBackend_, $rootScope) => {
|
|
$httpBackend = _$httpBackend_;
|
|
$scope = $rootScope.$new();
|
|
$scope.model = {
|
|
data: [
|
|
{itemFk: 1},
|
|
{itemFk: 2}
|
|
]
|
|
};
|
|
|
|
$state.params.id = 1;
|
|
const $element = angular.element('<vn-order-volume></vn-order-volume>');
|
|
controller = $componentController('vnOrderVolume', {$element, $scope});
|
|
}));
|
|
|
|
it('should join the sale volumes to its respective sale', () => {
|
|
let response = {
|
|
volumes: [
|
|
{itemFk: 1, volume: 0.008},
|
|
{itemFk: 2, volume: 0.003}
|
|
]
|
|
};
|
|
|
|
$httpBackend.expectGET(`Orders/1/getVolumes`).respond(response);
|
|
controller.onDataChange();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.$.model.data[0].volume).toBe(0.008);
|
|
expect(controller.$.model.data[1].volume).toBe(0.003);
|
|
});
|
|
});
|
|
});
|