From ee52460014c7e08fcda0a18ddad003c9f44653fc Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Mon, 31 Mar 2008 12:07:46 -0500 Subject: [PATCH] Refactored unittest.js so that it does not rely on Selector methods. (Easier to debug Selector test failures.) --- test/lib/unittest.js | 17 +++++++++++------ test/unit/selector.html | 15 +++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/lib/unittest.js b/test/lib/unittest.js index e32617b..e4dd197 100644 --- a/test/lib/unittest.js +++ b/test/lib/unittest.js @@ -86,15 +86,17 @@ Test.Unit.Logger = Class.create({ initialize: function(element) { this.element = $(element); if (this.element) this._createLogTable(); + this.tbody = $(this.element.getElementsByTagName('tbody')[0]); }, start: function(testName) { if (!this.element) return; - this.element.down('tbody').insert('' + testName + ''); + this.tbody.insert('' + testName + ''); }, setStatus: function(status) { - this.getLastLogLine().addClassName(status).down('td', 1).update(status); + this.getLastLogLine().addClassName(status); + $(this.getLastLogLine().getElementsByTagName('td')[1]).update(status); }, finish: function(status, summary) { @@ -110,15 +112,18 @@ Test.Unit.Logger = Class.create({ summary: function(summary) { if (!this.element) return; - this.element.down('div').update(this._toHTML(summary)); + var div = $(this.element.getElementsByTagName('div')[0]); + div.update(this._toHTML(summary)); }, getLastLogLine: function() { - return this.element.select('tr').last() + var trs = this.element.getElementsByTagName('tr'); + return $(trs[trs.length - 1]); }, getMessageCell: function() { - return this.getLastLogLine().down('td', 2); + var tds = this.getLastLogLine().getElementsByTagName('td'); + return $(tds[2]); }, _createLogTable: function() { @@ -144,7 +149,7 @@ Test.Unit.Logger = Class.create({ }, _toHTML: function(txt) { - return txt.escapeHTML().replace(/\n/g,"
"); + return txt.escapeHTML().replace(/\n/g,"
"); } }); diff --git a/test/unit/selector.html b/test/unit/selector.html index 50e4c55..3c00d51 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -167,8 +167,8 @@ }, testSelectorWithTagNameAndWhitespaceTokenizedAttributeValue: function() { - this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~="internal"]')); - this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~=internal]')); + this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~="internal"]'), "a[class~=\"internal\"]"); + this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~=internal]'), "a[class~=internal]"); }, testSelectorWithAttributeAndNoTagName: function() { @@ -199,12 +199,14 @@ }, test$$WithNestedAttributeSelectors: function() { - this.assertEnumEqual([$('strong')], $$('div[style] p[id] strong')); + this.assertEnumEqual([$('strong')], $$('div[style] p[id] strong'), 'div[style] p[id] strong'); }, testSelectorWithMultipleConditions: function() { - this.assertEnumEqual([$('link_3')], $$('a[class~=external][href="#"]')); - this.assertEnumEqual([], $$('a[class~=external][href!="#"]')); + this.assertEnumEqual([$('link_3')], $$('a[class~=external][href="#"]'), + 'a[class~=external][href="#"]'); + this.assertEnumEqual([], $$('a[class~=external][href!="#"]'), + 'a[class~=external][href!="#"]'); }, testSelectorMatchElements: function() { @@ -393,7 +395,8 @@ testSelectorWithEmpty: function() { $('level3_1').innerHTML = ""; - this.assertEnumEqual($('level3_1', 'level3_2', 'level2_3'), $$('#level1 *:empty')); + this.assertEnumEqual($('level3_1', 'level3_2', 'level2_3'), + $$('#level1 *:empty'), '#level1 *:empty'); this.assertEnumEqual([], $$('#level_only_child:empty'), 'newlines count as content!'); },