import './index.js';

describe('component vnShelvingDescriptor', () => {
    let $httpBackend;
    let controller;

    const shelving = {id: 1, code: 'AA6'};

    beforeEach(ngModule('shelving'));

    beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
        $httpBackend = _$httpBackend_;
        controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving});
        jest.spyOn(controller.vnApp, 'showSuccess');
    }));

    describe('onDelete()', () => {
        it('should delete entity and go to index', () => {
            controller.$state.go = jest.fn();

            $httpBackend.expectDELETE('Shelvings/1').respond();
            controller.onDelete();
            $httpBackend.flush();

            expect(controller.$state.go).toHaveBeenCalledWith('shelving.index');
            expect(controller.vnApp.showSuccess).toHaveBeenCalled();
        });
    });
});