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

35 lines
1.1 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Order', () => {
describe('Component vnOrderCreate', () => {
let $scope;
let controller;
beforeEach(ngModule('order'));
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$scope.card = {createOrder: () => {}};
2020-03-17 14:18:02 +00:00
const $element = angular.element('<vn-order-create></vn-order-create>');
controller = $componentController('vnOrderCreate', {$element, $scope});
}));
describe('onSubmit()', () => {
it(`should call createOrder()`, () => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller.$.card, 'createOrder');
controller.onSubmit();
expect(controller.$.card.createOrder).toHaveBeenCalledWith();
});
it(`should call go()`, async() => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller.$state, 'go');
await controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined});
});
});
});
});