const test = require('tape')
const models = require('./index')
const rootBus = require('minibus').create()

test('bus', t => {
  const busFactory = models.bus(rootBus, (obj, ev) => {
    return obj.foo === ev.baz && ev.baz === 'bar'
  })

  const obj = {
    foo: 'bar'
  }

  const bus = busFactory(obj)

  let calls = 0
  bus.on('test-event', function (ev) {
    calls += 1
  })

  // Send three test events. Only two should pass the test.
  rootBus.emit('test-event', {
    baz: 'bar'
  })
  rootBus.emit('test-event', {
    baz: '666'
  })
  rootBus.emit('test-event', {
    baz: 'bar'
  })
  // Fourth event with correct ev but wrong event name
  rootBus.emit('other-event', {
    baz: 'bar'
  })

  t.equal(calls, 2, 'number of calls')
  t.end()
})

@@ -156,17 +156,8 @@
 bus(
-rootBus, 
 (obj
@@ -287,16 +287,25 @@
 tory(obj
+, rootBus
 )%0A%0A  let

Repair tests