/*globals define, window*/

define([
    'jquery',
    'testsuite/qunit',
    './gadgetdialog',

    'ep/ui/dialog',
    '$ready!'
    /**
     * gadgetsdialog test case: constants
     * @param  {[type]} $               jQuery
     * @param  {[type]} QUnit           QUnit
     * @param  {[type]} gadgetdialog    Instance of main view
     */
], function ($, QUnit, gadgetdialog) {
    'use strict';

    var options = {
        gadget: {
            alias: 'rss',
            options: {}
        },
        callback: $.noop
    };

    QUnit.module('de_epages/externalcontent/gadgetdialog', {
        setup: function () {
            gadgetdialog.open(options);
        },
        teardown: function () {}
    });

    QUnit.test('Test *open* method', function () {

        QUnit.equal(
            $.isFunction(gadgetdialog.open),
            true,
            'Test if *open* is a function of *gadgetdialog*'
        );

        // stop test and wait for dialog to be ready
        QUnit.stop();
        window.setTimeout(function () {
            QUnit.equal(
                $('.ui-dialog').length > 0 && $('.ui-dialog').is(':visible'),
                true,
                'Check if gadget dialog is created and visible'
            );
            QUnit.start();
        }, 200);
    });
});