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

43 lines
1.3 KiB
JavaScript
Raw Normal View History

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_;
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
$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
});