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

30 lines
901 B
JavaScript
Raw Normal View History

2019-08-29 11:16:38 +00:00
import './index.js';
describe('Order Component vnOrderDescriptor', () => {
let $httpBackend;
let controller;
const order = {id: 1};
2019-08-29 11:16:38 +00:00
2020-03-17 14:18:02 +00:00
beforeEach(ngModule('order'));
2019-08-29 11:16:38 +00:00
beforeEach(inject(($componentController, _$httpBackend_) => {
2019-08-29 11:16:38 +00:00
$httpBackend = _$httpBackend_;
controller = $componentController('vnOrderDescriptor', {$element: null}, {order});
2019-08-29 11:16:38 +00:00
}));
describe('deleteOrder()', () => {
it(`should perform a DELETE query`, () => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.$state, 'go');
2019-08-29 11:16:38 +00:00
$httpBackend.expectDELETE(`Orders/${order.id}`).respond();
controller.deleteOrder();
2019-08-29 11:16:38 +00:00
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
2019-08-29 11:16:38 +00:00
expect(controller.$state.go).toHaveBeenCalledWith('order.index');
});
});
});