import './index';

describe(' Component vnRequestSearchPanel', () => {
    let controller;

    beforeEach(ngModule('item'));

    beforeEach(inject($componentController => {
        controller = $componentController('vnRequestSearchPanel', {$element: null});
        controller.$t = () => {};
        controller.filter = {};
    }));

    describe('from() setter', () => {
        it('should clear the scope days when setting the from property', () => {
            controller.filter.scopeDays = 1;

            controller.from = new Date();

            expect(controller.filter.scopeDays).toBeNull();
            expect(controller.from).toBeDefined();
        });
    });

    describe('to() setter', () => {
        it('should clear the scope days when setting the to property', () => {
            controller.filter.scopeDays = 1;

            controller.to = new Date();

            expect(controller.filter.scopeDays).toBeNull();
            expect(controller.to).toBeDefined();
        });
    });

    describe('scopeDays() setter', () => {
        it('should clear the date range when setting the scopeDays property', () => {
            controller.filter.from = new Date();
            controller.filter.to = new Date();

            controller.scopeDays = 1;

            expect(controller.filter.from).toBeNull();
            expect(controller.filter.to).toBeNull();
            expect(controller.scopeDays).toBeDefined();
        });
    });
});