Mercurial > browser-couch
changeset 53:08f868fc6e2b
Added a unit test for the web worker map reducer, and added the ability to skip tests into the test framework.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 14 Apr 2009 17:35:22 -0700 |
parents | 96379dbafc53 |
children | 3607a6844691 |
files | index.css index.html tests.js |
diffstat | 3 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/index.css Tue Apr 14 17:22:54 2009 -0700 +++ b/index.css Tue Apr 14 17:35:22 2009 -0700 @@ -24,5 +24,8 @@ } .pending { +} + +.skipped { background-color: lightGrey; }
--- a/index.html Tue Apr 14 17:22:54 2009 -0700 +++ b/index.html Tue Apr 14 17:35:22 2009 -0700 @@ -34,6 +34,11 @@ div.textContent = test.name + " running"; div.className = "test in-progress"; }, + onSkip: function(test) { + var div = document.getElementById("test_" + test.id); + div.textContent = test.name + " SKIPPED"; + div.className = "test skipped"; + }, onFinish: function(test) { var div = document.getElementById("test_" + test.id); div.textContent = test.name + " OK";
--- a/tests.js Tue Apr 14 17:22:54 2009 -0700 +++ b/tests.js Tue Apr 14 17:35:22 2009 -0700 @@ -29,6 +29,10 @@ if (nextTest < tests.length) { var test = tests[nextTest]; listener.onRun(test); + test.skip = function() { + listener.onSkip(this); + setTimeout(runNextTest, 0); + }; test.done = function() { listener.onFinish(this); setTimeout(runNextTest, 0); @@ -167,6 +171,30 @@ }}); }); }, + testViewMapReduceWebWorker_async: function(self) { + if (window.Worker) { + var map = this._mapWordFrequencies; + var reduce = this._reduceWordFrequencies; + this._setupTestDb( + function(db) { + db.view( + {map: map, + reduce: reduce, + mapReducer: new WebWorkerMapReducer(2), + chunkSize: 1, + finished: function(result) { + var expected = {rows: [{key: "dogen", value: 1}, + {key: "dude", value: 1}, + {key: "hello", value: 2}, + {key: "there", value: 2}]}; + self.assertEqual(JSON.stringify(expected), + JSON.stringify(result)); + self.done(); + }}); + }); + } else + self.skip(); + }, testViewMapReduce_async: function(self) { var map = this._mapWordFrequencies; var reduce = this._reduceWordFrequencies;