/*globals define, require, start*/
/*jslint nomen: true*/
define([
'jquery',
'testsuite/qunit',
'de_epages/externalcontent/gadgetdialog/externalvideo-view',
'$ready!'
/**
* gadgetsdialog test case: externalvideo-view
* @param {[type]} $ jQuery
* @param {[type]} QUnit QUnit
* @param {[type]} CONST constants
*/
], function ($, QUnit, ExternalvideoView) {
'use strict';
var externalvideoView,
fixture = $('#qunit-fixture'),
defaults = {},
modified = {};
QUnit.module('de_epages/externalcontent/gadgetdialog/externalvideo-view', {
setup: function () {
externalvideoView = new ExternalvideoView();
externalvideoView.render().$el.appendTo(fixture);
},
teardown: function () {}
});
QUnit.test('Check methods', function () {
QUnit.strictEqual(
$.isFunction(externalvideoView.onVideoInput),
true,
'Check if *onVideoInput* is a function of the prototype object'
);
});
QUnit.test('Check if content is rendered', function () {
QUnit.strictEqual(
fixture.find('form').length > 0,
true,
'Check if form is present'
);
});
QUnit.test('Check url validation and preview rendering', function () {
$('input[name="video"]').val('ThisIsNotValid').trigger('change');
QUnit.strictEqual(
$('form span.message-icon').hasClass('fail-icon'),
true,
'Check if FAIL is shown when entering an invalid url'
);
});
QUnit.test('Check options', function () {
defaults = {
'width': 560,
'height': 315
};
// after changing the values are stingified ($('#width').val(200).trigger('change');)
modified = {
'width': "200",
'height': "150"
};
QUnit.deepEqual(
externalvideoView.gOptions,
defaults,
'Check default options'
);
$('#width').val(200).trigger('change');
$('#height').val(150).trigger('change');
QUnit.deepEqual(
externalvideoView.gOptions,
modified,
'Check modified values'
);
});
// TODO: Test manipulating options (gOptions // width // height // ...)
});