Commit 8dd12afd authored by Thibaut Frain's avatar Thibaut Frain

Added Bootstrap wysiwyg tests and tests passed

parent 2056f6ce
<!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="../src/lib/qunit/qunit.css">
<script src="../src/lib/jquery.js"></script>
<script src="../src/lib/qunit/qunit.js"></script>
<script src="../src/lib/sinon/sinon.js"></script>
<script src="../src/lib/jschannel.js"></script>
<script src="../src/lib/renderjs.js"></script>
<script src="bw-gadget-test.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="gadget" style="display:none;"></div>
</body>
</html>
/*global window, document, QUnit, jQuery, rJS, sinon */
/*jslint indent: 2, maxerr: 3, maxlen: 79 */
"use strict";
QUnit.config.testTimeout = 1000;
(function (window, $, QUnit, rJS) {
//var test = QUnit.test,
var asyncTest = QUnit.asyncTest,
//stop = QUnit.stop,
start = QUnit.start,
//ok = QUnit.ok,
equal = QUnit.equal,
//expect = QUnit.expect,
//throws = QUnit.throws,
//deepEqual = QUnit.deepEqual;
bwGadgetURL = '../deploy/gadget/bootstrap-wysiwyg.html';
function iframeSelector(selectorString) {
return $('iframe').contents().find(selectorString);
}
rJS(window).ready(function () {
var g = rJS(this),
gadget_context = g.context.find('#gadget').first();
asyncTest("Bootstrap wysiwyg loading", 1, function () {
g.declareIframedGadget(bwGadgetURL, gadget_context)
.then(function () {
var edattr = iframeSelector("#editor").attr('contenteditable');
equal(edattr,"true");
})
.always(start);
});
asyncTest("Bootstrap wysiwyg loading : textarea is empty", 1, function () {
g.declareIframedGadget(bwGadgetURL, gadget_context)
.then(function () {
var ed = iframeSelector("#editor");
equal(ed.html(),"");
})
.always(start);
});
asyncTest("clear content of editor", 1, function () {
g.declareIframedGadget(bwGadgetURL, gadget_context)
.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.declareIframedGadget(bwGadgetURL, gadget_context)
.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.declareIframedGadget(bwGadgetURL, gadget_context)
.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