Skip to content

Commit

Permalink
unit tests for features
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed May 31, 2010
1 parent 3fe11df commit 21f638e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/wysihat/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ WysiHat.BrowserFeatures = (function() {
function detectIndentType(document) {
document.body.innerHTML = 'tab';
document.execCommand('indent', false, null);
console.log(document.body.innerHTML);

var tagName;
element = document.body.childNodes[0];
Expand Down
21 changes: 21 additions & 0 deletions test/unit/features_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
new Test.Unit.Runner({
testDetectParagraphType: function() {
var runner = this;

if (Prototype.Browser.WebKit)
runner.assertEqual("div", WysiHat.BrowserFeatures.paragraphType);
else if (Prototype.Browser.Gecko)
runner.assertEqual("br", WysiHat.BrowserFeatures.paragraphType);
else if (Prototype.Browser.IE)
runner.assertEqual("p", WysiHat.BrowserFeatures.paragraphType);
},

testDetectIndentType: function() {
var runner = this;

if (Prototype.Browser.WebKit || Prototype.Browser.IE)
runner.assertEqual(true, WysiHat.BrowserFeatures.indentInsertsBlockquote);
else if (Prototype.Browser.Gecko)
runner.assertEqual(false, WysiHat.BrowserFeatures.indentInsertsBlockquote);
}
});
3 changes: 3 additions & 0 deletions test/unit/fixtures/features.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script type="text/javascript">
WysiHat.BrowserFeatures.run();
</script>
6 changes: 4 additions & 2 deletions test/unit/templates/default.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
<title>Unit test file | <%= title %> | <%= template_name %> template | <%= timestamp %></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<%= lib_files %>
<script src="assets/prototype.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/wysihat.js" type="text/javascript" charset="utf-8"></script>
<%= css_fixtures %>
<%= js_fixtures %>
<%#= js_fixtures %>
<script src="lib_assets/unittest.js" type="text/javascript" charset="utf-8"></script>
<%= test_file %>
</head>
<body>
Expand All @@ -17,4 +19,4 @@

<%= html_fixtures %>
</body>
</html>
</html>

0 comments on commit 21f638e

Please sign in to comment.