Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added more tests for errors.jquery.js.

  • Loading branch information...
commit bcddab5c3aec4d0080d10725de20175f3ca9e9af 1 parent 50c688c
@toolness authored
Showing with 38 additions and 3 deletions.
  1. +38 −3 test/test-errors.jquery.js
View
41 test/test-errors.jquery.js
@@ -1,6 +1,6 @@
-module("jQuery.fn.fillError()");
+module("errors.jquery.js");
-test("raises nice exception when template is not found", function() {
+test("$.fn.fillError() raises nice err when template not found", function() {
try {
var div = $('<div></div>').fillError({type: "BLARGY"});
} catch (e) {
@@ -10,7 +10,7 @@ test("raises nice exception when template is not found", function() {
ok(false, "Exception not thrown!");
});
-test("works when template is found", function() {
+test("$.fn.fillError() works when template is found", function() {
var templates = $('<div class="error-msg BLARGY">' +
'<p>{{foo.bar}}</p></div>');
var div = $('<div></div>').fillError({
@@ -19,3 +19,38 @@ test("works when template is found", function() {
}, templates);
equal(div.html(), "<p>hi</p>");
});
+
+test("$.fn.errorHighlightInterval() works", function() {
+ deepEqual($('<div data-highlight="1"></div>').errorHighlightInterval(),
+ {start: 1, end: undefined}, "works w/ start only");
+ deepEqual($('<div data-highlight="1,2"></div>').errorHighlightInterval(),
+ {start: 1, end: 2}, "works w/ number pair");
+});
+
+test("$.fn.eachErrorHighlight() works", function() {
+ var args = [];
+ var div = $('<div><div data-highlight="1,2"></div>' +
+ '<em data-highlight="3"></em></div>');
+ div.eachErrorHighlight(function(start, end, i) {
+ args.push({
+ node: this.nodeName,
+ start: start,
+ end: end,
+ i: i
+ });
+ });
+ deepEqual(args, [
+ {
+ "end": 2,
+ "i": 0,
+ "node": "DIV",
+ "start": 1
+ },
+ {
+ "end": undefined,
+ "i": 1,
+ "node": "EM",
+ "start": 3
+ }
+ ]);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.