Mercurial > browser-couch
comparison tests.js @ 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 | 6da7638d056f |
children | 3607a6844691 |
comparison
equal
deleted
inserted
replaced
52:96379dbafc53 | 53:08f868fc6e2b |
---|---|
27 | 27 |
28 function runNextTest() { | 28 function runNextTest() { |
29 if (nextTest < tests.length) { | 29 if (nextTest < tests.length) { |
30 var test = tests[nextTest]; | 30 var test = tests[nextTest]; |
31 listener.onRun(test); | 31 listener.onRun(test); |
32 test.skip = function() { | |
33 listener.onSkip(this); | |
34 setTimeout(runNextTest, 0); | |
35 }; | |
32 test.done = function() { | 36 test.done = function() { |
33 listener.onFinish(this); | 37 listener.onFinish(this); |
34 setTimeout(runNextTest, 0); | 38 setTimeout(runNextTest, 0); |
35 }; | 39 }; |
36 test.func.call(container, test); | 40 test.func.call(container, test); |
165 self.assertEqual(view.findRow("there"), 3); | 169 self.assertEqual(view.findRow("there"), 3); |
166 self.done(); | 170 self.done(); |
167 }}); | 171 }}); |
168 }); | 172 }); |
169 }, | 173 }, |
174 testViewMapReduceWebWorker_async: function(self) { | |
175 if (window.Worker) { | |
176 var map = this._mapWordFrequencies; | |
177 var reduce = this._reduceWordFrequencies; | |
178 this._setupTestDb( | |
179 function(db) { | |
180 db.view( | |
181 {map: map, | |
182 reduce: reduce, | |
183 mapReducer: new WebWorkerMapReducer(2), | |
184 chunkSize: 1, | |
185 finished: function(result) { | |
186 var expected = {rows: [{key: "dogen", value: 1}, | |
187 {key: "dude", value: 1}, | |
188 {key: "hello", value: 2}, | |
189 {key: "there", value: 2}]}; | |
190 self.assertEqual(JSON.stringify(expected), | |
191 JSON.stringify(result)); | |
192 self.done(); | |
193 }}); | |
194 }); | |
195 } else | |
196 self.skip(); | |
197 }, | |
170 testViewMapReduce_async: function(self) { | 198 testViewMapReduce_async: function(self) { |
171 var map = this._mapWordFrequencies; | 199 var map = this._mapWordFrequencies; |
172 var reduce = this._reduceWordFrequencies; | 200 var reduce = this._reduceWordFrequencies; |
173 this._setupTestDb( | 201 this._setupTestDb( |
174 function(db) { | 202 function(db) { |