2018-08-09 13:42:21 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Order', () => {
|
|
|
|
describe('Component vnOrderCreate', () => {
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('order'));
|
2018-08-09 13:42:21 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
2018-08-09 13:42:21 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.card = {createOrder: () => {}};
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnOrderCreate', {$scope});
|
2018-08-09 13:42:21 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should call createOrder()`, () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.$.card, 'createOrder');
|
2018-08-09 13:42:21 +00:00
|
|
|
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');
|
2018-08-09 13:42:21 +00:00
|
|
|
await controller.onSubmit();
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined});
|
2018-08-09 13:42:21 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|