salix/modules/order/front/volume/index.spec.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

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;
2020-03-17 14:18:02 +00:00
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();
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);
});
});
});