forked from noflo/noflo-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Kick component to work on browser, refs noflo#63
- Loading branch information
Showing
5 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
if typeof process is 'object' and process.title is 'node' | ||
chai = require 'chai' unless chai | ||
kick = require '../src/components/Kick.coffee' | ||
socket = require '../src/lib/InternalSocket.coffee' | ||
else | ||
kick = require 'noflo/components/Kick.js' | ||
socket = require 'noflo/lib/InternalSocket.js' | ||
|
||
describe 'Kick component', -> | ||
c = null | ||
ins = null | ||
data = null | ||
out = null | ||
beforeEach -> | ||
c = kick.getComponent() | ||
ins = socket.createSocket() | ||
data = socket.createSocket() | ||
out = socket.createSocket() | ||
c.inPorts.in.attach ins | ||
c.inPorts.data.attach data | ||
c.outPorts.out.attach out | ||
|
||
it 'should not send packets before disconnect', (done) -> | ||
sent = false | ||
out.once 'data', (d) -> | ||
sent = true | ||
setTimeout -> | ||
chai.expect(sent).to.be.false | ||
done() | ||
, 5 | ||
data.send 'Bar' | ||
ins.send 'Foo' | ||
|
||
it 'should send a null on disconnect when no data has been specified', (done) -> | ||
out.once 'data', (d) -> | ||
chai.expect(d).to.be.null | ||
done() | ||
ins.send 'Foo' | ||
ins.disconnect() | ||
|
||
it 'should send correct data on disconnect', (done) -> | ||
out.once 'data', (d) -> | ||
chai.expect(d).to.equal 'Baz' | ||
done() | ||
data.send 'Bar' | ||
data.send 'Baz' | ||
ins.send 'Foo' | ||
ins.disconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters