2019-08-29 11:16:38 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Order Component vnOrderDescriptor', () => {
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
2020-04-30 10:48:52 +00:00
|
|
|
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
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2019-08-29 11:16:38 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-04-30 10:48:52 +00:00
|
|
|
controller = $componentController('vnOrderDescriptor', {$element: null}, {order});
|
2019-08-29 11:16:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('deleteOrder()', () => {
|
2020-04-30 10:48:52 +00:00
|
|
|
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
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
$httpBackend.expectDELETE(`Orders/${order.id}`).respond();
|
|
|
|
controller.deleteOrder();
|
2019-08-29 11:16:38 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2019-08-29 11:16:38 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('order.index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|