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

30 lines
937 B
JavaScript
Raw Normal View History

2022-05-24 10:50:22 +00:00
import './index.js';
2022-07-20 11:41:33 +00:00
describe('component vnShelvingDescriptor', () => {
2022-05-24 10:50:22 +00:00
let $httpBackend;
let controller;
2022-07-20 11:41:33 +00:00
const shelving = {id: 1, code: 'AA6'};
beforeEach(ngModule('shelving'));
2022-05-24 10:50:22 +00:00
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
$httpBackend = _$httpBackend_;
2022-07-20 11:41:33 +00:00
controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving});
jest.spyOn(controller.vnApp, 'showSuccess');
2022-05-24 10:50:22 +00:00
}));
2022-07-20 11:41:33 +00:00
describe('onDelete()', () => {
it('should delete entity and go to index', () => {
controller.$state.go = jest.fn();
2022-05-24 10:50:22 +00:00
2022-07-20 11:41:33 +00:00
$httpBackend.expectDELETE('Shelvings/1').respond();
controller.onDelete();
2022-05-24 10:50:22 +00:00
$httpBackend.flush();
2022-07-20 11:41:33 +00:00
expect(controller.$state.go).toHaveBeenCalledWith('shelving.index');
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
2022-05-24 10:50:22 +00:00
});
});
});