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: () => {}}; const $element = angular.element(''); controller = $componentController('vnOrderCreate', {$element, $scope}); })); describe('onSubmit()', () => { it(`should call createOrder()`, () => { jest.spyOn(controller.$.card, 'createOrder'); controller.onSubmit(); expect(controller.$.card.createOrder).toHaveBeenCalledWith(); }); it(`should call go()`, async() => { jest.spyOn(controller.$state, 'go'); await controller.onSubmit(); expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined}); }); }); }); });