Skip to content

Commit

Permalink
Use the getStream API
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Jan 18, 2017
1 parent 6ae0d30 commit 76cd3fd
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions spec/Component.coffee
Expand Up @@ -1429,6 +1429,26 @@ describe 'Component', ->
c.inPorts.in.attach sin1
sin1.post new noflo.IP 'data', 'eh'

it 'should get full stream when it has a single packet stream and it should clear it', (done) ->
c = new noflo.Component
inPorts:
eh:
datatype: 'string'
outPorts:
canada:
datatype: 'string'
process: (input, output) ->
return unless input.hasStream 'eh'
stream = input.getStream 'eh'
packetTypes = stream.map (ip) -> [ip.type, ip.data]
chai.expect(packetTypes).to.eql [
['data', 'moose']
]
chai.expect(input.has('eh')).to.equal false
done()

c.inPorts.eh.attach sin1
sin1.post new noflo.IP 'data', 'moose'
it 'should get full stream when it has a full stream, and it should clear it', (done) ->
c = new noflo.Component
inPorts:
Expand All @@ -1439,16 +1459,23 @@ describe 'Component', ->
datatype: 'string'
process: (input, output) ->
return unless input.hasStream 'eh'
originalBuf = input.buffer.get 'eh'
stream = input.getStream 'eh'
afterStreamBuf = input.buffer.get 'eh'
chai.expect(stream).to.eql originalBuf
chai.expect(afterStreamBuf).to.eql []
packetTypes = stream.map (ip) -> [ip.type, ip.data]
chai.expect(packetTypes).to.eql [
['openBracket', null]
['openBracket', 'foo']
['data', 'moose']
['closeBracket', 'foo']
['closeBracket', null]
]
chai.expect(input.has('eh')).to.equal false
done()

c.inPorts.eh.attach sin1
sin1.post new noflo.IP 'openBracket'
sin1.post new noflo.IP 'openBracket', 'foo'
sin1.post new noflo.IP 'data', 'moose'
sin1.post new noflo.IP 'closeBracket', 'foo'
sin1.post new noflo.IP 'closeBracket'

describe 'with a simple ordered stream', ->
Expand Down

0 comments on commit 76cd3fd

Please sign in to comment.