Skip to content
Browse files

Add spec for default value

  • Loading branch information...
1 parent 671afe1 commit be8e04467551586ee9d9bbf82962e6a8ee2c3236 Kenneth Kan committed Mar 2, 2014
Showing with 18 additions and 0 deletions.
  1. +18 −0 spec/InPort.coffee
View
18 spec/InPort.coffee
@@ -35,3 +35,21 @@ describe 'Inport Port', ->
chai.expect(p.isConnected()).to.equal false
it 'should not contain a socket initially', ->
chai.expect(p.sockets.length).to.equal 0
+
+ describe 'with default value', ->
+ p = s = null
+ beforeEach ->
+ p = new inport
+ default: 'default-value'
+ s = new socket
+ p.attach s
+ it 'should send the default value as a packet, though on next tick after initialization', (done) ->
+ p.config.on 'data', (data) ->
+ chai.expect(data).toEqual 'default-value'
+ done()
+ it 'should send the default value before IIP', (done) ->
+ received = ['default-value', 'some-iip']
+ p.config.on 'data', (data) ->
+ chai.expect(data).toEqual received.shift()
+ done() if received.length is 0
+ s.send 'some-iip'

0 comments on commit be8e044

Please sign in to comment.
Something went wrong with that request. Please try again.