Skip to content

Commit

Permalink
Add test for event forwarding from a subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Dec 3, 2017
1 parent 1ec99a5 commit ed24bfb
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions spec/Subgraph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,49 @@ describe 'NoFlo Graph component', ->
return done err if err
sendNext()
return
describe 'event forwarding on parent network', ->
graph = null
network = null
before (done) ->
graph = new noflo.Graph 'main'
graph.baseDir = root
network = new noflo.Network graph
network.loader.listComponents (err) ->
return done err if err
network.loader.components.Split = Split
network.loader.components.Merge = SubgraphMerge
sg = new noflo.Graph 'Subgraph'
sg.addNode 'A', 'Split'
sg.addNode 'B', 'Merge'
sg.addEdge 'A', 'out', 'B', 'in'
sg.addInport 'in', 'A', 'in'
sg.addOutport 'out', 'B', 'out'
network.loader.registerGraph 'foo', 'AB', sg, (err) ->
return done err if err
network.connect done
it 'should instantiate the subgraph when node is added', (done) ->
setTimeout ->
chai.expect(network.processes).not.to.be.empty
chai.expect(network.processes.Sub).to.exist
done()
, 10
graph.addNode 'Sub', 'foo/AB'
graph.addNode 'Split', 'Split'
graph.addEdge 'Sub', 'out', 'Split', 'in'
it 'should be possible to start the graph', (done) ->
network.start done
it 'should forward IP events', (done) ->
network.once 'ip', (ip) ->
chai.expect(ip.id).to.equal 'DATA -> IN Sub()'
chai.expect(ip.type).to.equal 'data'
chai.expect(ip.data).to.equal 'foo'
chai.expect(ip.subgraph).to.be.undefined
network.once 'ip', (ip) ->
chai.expect(ip.id).to.equal 'A() OUT -> IN B()'
chai.expect(ip.type).to.equal 'data'
chai.expect(ip.data).to.equal 'foo'
chai.expect(ip.subgraph).to.eql [
'Sub'
]
done()
graph.addInitial 'foo', 'Sub', 'in'

0 comments on commit ed24bfb

Please sign in to comment.