salix/modules/order/front/basic-data/index.spec.js

41 lines
1.3 KiB
JavaScript

import './index.js';
describe('Order', () => {
describe('Component vnOrderBasicData', () => {
let $httpBackend;
let controller;
let $scope;
beforeEach(ngModule('order'));
beforeEach(inject(($compile, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$httpBackend.whenRoute('GET', 'Addresses')
.respond([{id: 2, nickname: 'address 2'}]);
$httpBackend.whenRoute('GET', 'Clients')
.respond([{id: 1, defaultAddressFk: 1}]);
$scope.order = {clientFk: 1, addressFk: 1};
let $element = $compile('<vn-order-basic-data order="order"></vn-order-basic-data>')($scope);
$httpBackend.flush();
controller = $element.controller('vnOrderBasicData');
}));
afterAll(() => {
$scope.$destroy();
$element.remove();
});
describe('constructor()', () => {
it('should update the address after the client changes', async() => {
controller.selection = {id: 2, defaultAddressFk: 2};
$scope.$digest();
expect(controller.order.addressFk).toEqual(2);
});
});
});
});