Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated tests for node-lazy interface, all pass

  • Loading branch information...
commit ff5b759714a804fb6b63c4d82621bc88b3f230af 1 parent 6751db9
@substack substack authored
Showing with 23 additions and 21 deletions.
  1. +8 −8 test/foreach.js
  2. +15 −13 test/json.js
View
16 test/foreach.js
@@ -17,15 +17,15 @@ exports['foreach'] = function (assert) {
function test_foreach() {
var expectedSum = 99*(99+1)/2;
var runningSum = 0;
- db.forEach(
- function (err, key, val) {
- assert.ok(!err);
- runningSum += val;
- },
- function () {
+ db
+ .forEach(function (row) {
+ runningSum += row.value;
+ })
+ .on('error', assert.fail)
+ .on('end', function () {
assert.equal(expectedSum, runningSum);
- }
- );
+ })
+ ;
}
});
}
View
28 test/json.js
@@ -30,21 +30,23 @@ exports['json'] = function (assert) {
assert.equal(value.location.country, 'usa');
assert.equal(value.location.state, 'alaska');
- db.forEach(function (fErr, key, val) {
- assert.ok(!fErr);
+ db
+ .on('error', assert.fail)
+ .forEach(function (row) {
+ var key = row.key, val = row.value;
assert.ok(key == 'pkrumins' || key == 'substack');
assert.ok(val.age == 22 || val.age == 25);
assert.ok(val.location == 'latvia' || val.location.country == 'usa');
- db.filter(
- function (key, val) {
- return val.age <= 22;
- },
- function (err, key, val) {
- assert.equal(key, 'substack');
- assert.equal(val.age, 22);
- },
- function () {
+ db
+ .filter(function (row) {
+ return row.value.age <= 22;
+ })
+ .join(function (rows) {
+ assert.equal(rows.length, 1);
+ assert.equal(rows[0].key, 'substack');
+ assert.equal(rows[0].value.age, 22);
+
db.all(function (aErr, keys, vals) {
assert.ok(!aErr);
assert.equal(keys.length, 2);
@@ -52,8 +54,8 @@ exports['json'] = function (assert) {
assert.ok('pkrumins' == keys[0] || 'pkrumins' == keys[1]);
assert.ok('substack' == keys[0] || 'substack' == keys[1]);
});
- }
- );
+ })
+ ;
})
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.