1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 19:39:57 +00:00
TiddlyWiki5/test/tiddlywiki.2.6.5/source/tiddlywiki/tests/jsspec/Messages.jsspec.js
Jeremy Ruston 07df513140 Revised test data
Testing against the output of cook.rb isn't satisfactory because of the
bugs in it; instead we're now going to test against the tiddlywiki.com
build products
2011-12-03 11:41:25 +00:00

40 lines
1.1 KiB
JavaScript
Executable File

// <![CDATA[
function getMessage() {
return msgArea.getElementsByTagName("div")[1].innerHTML;
}
describe('displayMessage',
{
before_each: function() {
msgArea = createTiddlyElement(document.body,"div","messageArea");
msgArea.style.visibility = "hidden"; },
after_each: function() {
removeNode(msgArea);
},
'should raise an alert if the messageArea element does not exist': function() {
msgArea.id = "messageArea_disabled";
var text = "alert this text!";
tests_mock.before('alert', function() {
tests_mock.frame['alert'].args = arguments;
});
displayMessage(text);
frame = tests_mock.after('alert');
value_of(frame.called).should_be(1);
value_of(frame.args[0]).should_be(text);
},
'should put single letter "s" into the message area': function() {
var text = "s";
displayMessage(text);
var actual = getMessage();
value_of(actual).should_be(text);
},
'should put text into the message area': function() {
var text = "The quick brown fox jumps over the lazy dog";
displayMessage(text);
var actual = getMessage();
value_of(actual).should_be(text);
}
});
// ]]>