2020-02-05 12:37:36 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('vnRouteDescriptorPopover', () => {
|
|
|
|
let controller;
|
2020-04-25 09:50:04 +00:00
|
|
|
let $httpBackend;
|
2020-02-05 12:37:36 +00:00
|
|
|
|
|
|
|
beforeEach(ngModule('route'));
|
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2020-02-05 12:37:36 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-04-30 10:48:52 +00:00
|
|
|
controller = $componentController('vnRouteDescriptor', {$element: null});
|
2020-04-25 09:50:04 +00:00
|
|
|
}));
|
2020-02-05 12:37:36 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
describe('loadData()', () => {
|
2020-02-05 12:37:36 +00:00
|
|
|
it(`should perform a get query to store the client data into the controller`, () => {
|
2020-04-25 09:50:04 +00:00
|
|
|
const id = 1;
|
|
|
|
const response = 'foo';
|
2020-02-05 12:37:36 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
$httpBackend.expectRoute('GET', `Routes/${id}`).respond(response);
|
2020-04-25 09:50:04 +00:00
|
|
|
controller.id = id;
|
2020-02-05 12:37:36 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.route).toEqual(response);
|
|
|
|
});
|
|
|
|
});
|
2022-11-15 07:24:10 +00:00
|
|
|
|
|
|
|
describe('deleteCurrentRoute()', () => {
|
|
|
|
it(`should perform a delete query to delete the current route`, () => {
|
|
|
|
const id = 1;
|
|
|
|
|
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
|
|
|
|
controller._id = id;
|
|
|
|
$httpBackend.expectDELETE(`Routes/${id}`).respond(200);
|
|
|
|
controller.deleteCurrentRoute();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.route).toBeUndefined();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Route deleted');
|
|
|
|
});
|
|
|
|
});
|
2020-02-05 12:37:36 +00:00
|
|
|
});
|