From c9c176a53b1632ca2b1c6ed27382ab72ac21d45d Mon Sep 17 00:00:00 2001 From: Adam Abrons Date: Tue, 5 Jan 2010 16:36:58 -0800 Subject: angular.js --- test/testabilityPatch.js | 129 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 test/testabilityPatch.js (limited to 'test/testabilityPatch.js') diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js new file mode 100644 index 00000000..5fca3524 --- /dev/null +++ b/test/testabilityPatch.js @@ -0,0 +1,129 @@ +TestCase = function(name) { return jstestdriver.testCaseManager.TestCase(name); }; + +HIDDEN = jQuery.browser.msie ? + '' : + jQuery.browser.safari ? + ' style="display: none; "' : + ' style="display: none;"'; + +nglr.msie = jQuery.browser.msie; +nglr.alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);}; + +function noop(){} + +jstd = jstestdriver; + +function html(content) { + return jQuery("
").html(content); +} + +function report(reportTest){ + $("#tests").children().each(function(i){ + var success = this.className == "pass"; + var strong = this.firstChild; + var msg = strong.firstChild.nodeValue; + var parts = msg.split(" module: "); + var module = parts[0]; + var name = parts[1].replace(/ *$/, ""); + reportTest(success, module, name, this.nodeValue); + }); +} + +MockUrlWatcher = function() { + this.url = "http://server"; +}; +MockUrlWatcher.prototype.getUrl = function(){ + return this.url; +}; +MockUrlWatcher.prototype.setUrl = function(url){ + this.url = url; +}; + +jQuery.fn.sortedHtml = function() { + var html = ""; + var toString = function(index, node) { + node = node || this; + if (node.nodeName == "#text") { + html += nglr.escapeHtml(node.nodeValue); + } else { + html += '<' + node.nodeName.toLowerCase(); + var attributes = node.attributes || []; + var attrs = []; + for(var i=0; i'; + } + }; + this.children().each(toString); + return html; +}; + +function encode64(obj){ + return Base64.encode(nglr.toJson(obj)); +} + +function decode64(base64){ + return nglr.fromJson(Base64.decode(base64)); +} + +nglr.Loader.prototype.configureJQueryPlugins(); + +function assertHidden(node) { + var display = node.css('display'); + assertEquals("Node should be hidden but vas visible: " + node.sortedHtml(), 'none', display); +} + +function assertVisible(node) { + var display = node.css('display'); + if (display == 'block') display = ""; + assertEquals("Node should be visible but vas hidden: " + node.sortedHtml(), '', display); +} + +function assertJsonEquals(expected, actual) { + assertEquals(nglr.toJson(expected), nglr.toJson(actual)); +} + +function assertUndefined(value) { + assertEquals('undefined', typeof value); +} + +function assertDefined(value) { + assertTrue(nglr.toJson(value), !!value); +} + +function assertThrows(error, fn){ + var exception = null; + try { + fn(); + } catch(e) { + exception = e; + } + if (!exception) { + fail("Expecting exception, none thrown"); + } + assertEquals(error, exception); +} \ No newline at end of file -- cgit v1.2.3