Permalink
Browse files

test that trigger can filter

  • Loading branch information...
1 parent 1ccc819 commit 1517b02320b027d3932d08c5d4318aa900645b0d @dominictarr committed May 28, 2013
Showing with 30 additions and 0 deletions.
  1. +30 −0 test/filter.js
View
@@ -0,0 +1,30 @@
+var levelup = require('level-test')()
+var sublevel = require('level-sublevel')
+var tape = require('tape')
+
+var mac = require('macgyver')().autoValidate()
+var Trigger = require('..')
+
+tape('filter', function (t) {
+
+ function okay (err) {
+ t.notOk(err)
+ }
+
+ var db = sublevel(levelup('level-trigger-test'))
+ var aggDb = db.sublevel('agg')
+ var trigDb = Trigger(db, 'even-triggers', mac(function (item) {
+ if(!(item.value % 2))
+ return item.value
+ }).twice(), mac(function (value, done) {
+ t.equal(+value, 2)
+ aggDb.put(value, value, function (err) {
+ t.notOk(err)
+ t.end()
+ })
+ }).once())
+
+ db.put('foo', '1', okay)
+ db.put('bar', '2', okay)
+
+})

0 comments on commit 1517b02

Please sign in to comment.