2019-02-06 13:56:36 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Order', () => {
|
|
|
|
describe('Component vnOrderBasicData', () => {
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('order'));
|
2019-02-06 13:56:36 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($compile, _$httpBackend_, $rootScope) => {
|
2019-02-06 13:56:36 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenRoute('GET', 'Addresses')
|
2019-02-06 13:56:36 +00:00
|
|
|
.respond([{id: 2, nickname: 'address 2'}]);
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenRoute('GET', 'Clients')
|
2019-02-06 13:56:36 +00:00
|
|
|
.respond([{id: 1, defaultAddressFk: 1}]);
|
2019-02-15 12:26:49 +00:00
|
|
|
$scope.order = {clientFk: 1, addressFk: 1};
|
2019-02-06 13:56:36 +00:00
|
|
|
|
|
|
|
let $element = $compile('<vn-order-basic-data order="order"></vn-order-basic-data>')($scope);
|
|
|
|
$httpBackend.flush();
|
|
|
|
controller = $element.controller('vnOrderBasicData');
|
|
|
|
}));
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
afterAll(() => {
|
|
|
|
$scope.$destroy();
|
|
|
|
$element.remove();
|
|
|
|
});
|
|
|
|
|
2019-02-06 13:56:36 +00:00
|
|
|
describe('constructor()', () => {
|
|
|
|
it('should update the address after the client changes', async() => {
|
|
|
|
controller.selection = {id: 2, defaultAddressFk: 2};
|
|
|
|
$scope.$digest();
|
|
|
|
|
2019-02-15 12:26:49 +00:00
|
|
|
expect(controller.order.addressFk).toEqual(2);
|
2019-02-06 13:56:36 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|