import './index.js';
describe('Component vnShelvingIndex', () => {
    let controller;
    let $window;
    let shelvings = [{
        id: 1,
        code: 'AAA'
    }, {
        id: 2,
        code: 'AA1'
    }, {
        id: 3,
        code: 'AA2'
    }];

    beforeEach(ngModule('shelving'));

    beforeEach(inject(($componentController, _$window_) => {
        $window = _$window_;
        const $element = angular.element('<vn-shelving-index></vn-shelving-index>');
        controller = $componentController('vnShelvingIndex', {$element});
    }));

    describe('preview()', () => {
        it('should show the dialog summary', () => {
            controller.$.summary = {show: () => {}};
            jest.spyOn(controller.$.summary, 'show');

            let event = new MouseEvent('click', {
                view: $window,
                bubbles: true,
                cancelable: true
            });
            controller.preview(event, shelvings[0]);

            expect(controller.$.summary.show).toHaveBeenCalledWith();
        });
    });
});