Skip to content

Instantly share code, notes, and snippets.

@automata
Created November 19, 2015 17:30
Show Gist options
  • Save automata/332ddf6b83b66c5900f9 to your computer and use it in GitHub Desktop.
Save automata/332ddf6b83b66c5900f9 to your computer and use it in GitHub Desktop.
noflo = require 'noflo'
unless noflo.isBrowser()
chai = require 'chai' unless chai
{%= component_name %} = require '../components/{%= component_name %}.coffee'
baseDir = path.resolve __dirname, '../'
testutils = require './testutils'
else
{%= component_name %} = require '{%= name %}/components/{%= component_name %}.js'
describe '{%= component_name %} component', ->
c = null
ins = null
out = null
unless noflo.isBrowser()
before (done) ->
@timeout 20000
loader = new noflo.ComponentLoader baseDir
loader.load '{%= name %}/{%= component_name %}', (err, instance) ->
instance = err unless instance
c = instance
c.once 'ready', ->
verbose = true
debugSubraphs = true
if process.env.DEBUG_NOFLO
testutils.addDebug c.network, verbose, debugSubraphs
c.start()
setTimeout done, 1
beforeEach ->
c = {%= component_name %}.getComponent()
ins = noflo.internalSocket.createSocket()
out = noflo.internalSocket.createSocket()
c.inPorts.in.attach ins
c.outPorts.out.attach out
afterEach ->
c.inPorts.in.detach ins
c.outPorts.out.detach out
ins = null
out = null
describe 'when instantiated', ->
it 'should have an input port', ->
chai.expect(c.inPorts.in).to.be.an 'object'
it 'should have an output port', ->
chai.expect(c.outPorts.out).to.be.an 'object'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment