import { Dialog } from '../Dialog';
import { DialogProvider } from '../DialogProvider';
import { DialogExtension } from './DialogExtension';
import { DialogProviderImpl } from './DialogProviderImpl';
import { DialogCreationOptions } from '../DialogCreationOptions';

describe('DialogModuleTesting', () => {
    const dialogExtension:DialogExtension = {
        addon_key: 'addon_key',
        key: 'key',
        options: {}
    };
    const dialogProvider:DialogProvider = new DialogProviderImpl();
    const dialogCreationOptions:any = {
        key: 'key',
        size: 'invalid size',
        width: '100%',
        height: '100%',
        chrome: true,
        header: 'header',
        actions: [],
        closeOnEscape: true,
        hint: ''
    };

    it('Should allow a product to throw an exception for invalid size', () => {
        expect(() => dialogProvider.create(dialogCreationOptions, dialogExtension)).toThrow('Invalid dialog size: invalid size');
    });

    it('Should allow dialog creation with valid size values', () => {
        ['small', 'medium', 'large', 'x-large', 'fullscreen', 'maximum'].forEach(size => {
            const options:any = Object.assign({}, dialogCreationOptions, {size});
            expect(() => dialogProvider.create(options, dialogExtension)).not.toThrow();
        });
    });

});
