Commit 7991fcc6 authored by Thibaut Frain's avatar Thibaut Frain

Added bootstrap_wysiwyg tests

parent 50b49c69
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height"/>
<title>Test Bootstrap Wysiwyg gadget</title>
<link rel="stylesheet" href="../<%= copy.qunitcss.relative_dest %>">
<script src="../<%= curl.jquery.relative_dest %>"></script>
<script src="../<%= copy.qunitjs.relative_dest %>"></script>
<script src="../<%= copy.rsvp.relative_dest %>"></script>
<script src="../<%= copy.renderjs.relative_dest %>"></script>
<script src="test.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="truc"></div>
</body>
</html>
/*global window, document, QUnit, jQuery, rJS*/
/*jslint indent: 2, maxerr: 3, maxlen: 79 */
(function (window, $, QUnit, rJS) {
"use strict";
QUnit.config.testTimeout = 1000;
var asyncTest = QUnit.asyncTest,
start = QUnit.start,
equal = QUnit.equal,
bwGadgetURL = 'index.html';
function iframeSelector(selectorString) {
return $('iframe').contents().find(selectorString);
}
rJS(window).ready(function (g) {
var gadget_context = $('#qunit-fixture')[0];
asyncTest("Bootstrap wysiwyg loading", 1, function () {
g.declareGadget(bwGadgetURL, {
element: gadget_context,
sandbox: 'iframe'
})
.then(function () {
var edattr = iframeSelector(".editor").attr('contenteditable');
equal(edattr, "true");
})
.always(start);
});
asyncTest("Bootstrap wysiwyg loading : textarea is empty", 1, function () {
g.declareGadget(bwGadgetURL, {
element: gadget_context,
sandbox: 'iframe'
})
.then(function () {
var ed = iframeSelector(".editor");
equal(ed.html(), "");
})
.always(start);
});
asyncTest("clear content of editor", 1, function () {
g.declareGadget(bwGadgetURL, {
element: gadget_context,
sandbox: 'iframe'
})
.then(function (gadget) {
iframeSelector('.editor').html('A value');
return gadget;
})
.then(function (gadget) {
return gadget.clearContent().then(function () {
equal(iframeSelector('.editor').text(), "");
});
})
.always(start);
});
asyncTest("get content of editor", 1, function () {
g.declareGadget(bwGadgetURL, {
element: gadget_context,
sandbox: 'iframe'
})
.then(function (gadget) {
iframeSelector('.editor').html('A value');
return gadget;
})
.then(function (gadget) {
return gadget.getContent().then(function (content) {
equal(content, "A value");
});
})
.always(start);
});
asyncTest("set content of sheet", 2, function () {
var gadget, content;
g.declareGadget(bwGadgetURL, {
element: gadget_context,
sandbox: 'iframe'
})
.then(function (gd) {
iframeSelector('.editor').html('A value');
gadget = gd;
return gadget.getContent();
})
.then(function (c) {
content = c;
return gadget.clearContent();
})
.then(function () {
equal(iframeSelector('.editor').text(), "");
return gadget.setContent(content);
})
.then(function () {
equal(iframeSelector('.editor').text(), "A value");
})
.always(start);
});
});
}(window, jQuery, QUnit, rJS));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment