Tarea #509 /create/card.js Front unit test
This commit is contained in:
parent
e3cfe9472f
commit
f0df298138
|
@ -9,7 +9,6 @@ class Controller {
|
||||||
|
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
let newOrderID = await this.$.card.createOrder();
|
let newOrderID = await this.$.card.createOrder();
|
||||||
console.log(newOrderID);
|
|
||||||
this.$state.go("order.card.summary", {id: newOrderID});
|
this.$state.go("order.card.summary", {id: newOrderID});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('Order', () => {
|
||||||
|
describe('Component vnOrderCreate', () => {
|
||||||
|
let $componentController;
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('order');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
||||||
|
$componentController = _$componentController_;
|
||||||
|
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.card = {createOrder: () => {}};
|
||||||
|
controller = $componentController('vnOrderCreate', {$scope: $scope});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should call createOrder()`, () => {
|
||||||
|
spyOn(controller.$.card, 'createOrder');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$.card.createOrder).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should call go()`, async() => {
|
||||||
|
spyOn(controller.$state, 'go');
|
||||||
|
await controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith("order.card.summary", {id: undefined});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue