Permalink
Browse files

Tests for Base64Encode

  • Loading branch information...
1 parent 84fcfb9 commit 1780641a5b9704314990edc826e2a6e1ab6edc82 @bergie bergie committed Apr 3, 2013
Showing with 42 additions and 0 deletions.
  1. +42 −0 test/Base64Encode.coffee
View
@@ -0,0 +1,42 @@
+component = require "../src/components/Base64Encode"
+socket = require "../src/lib/InternalSocket"
+
+setupComponent = ->
+ c = component.getComponent()
+ ins = socket.createSocket()
+ out = socket.createSocket()
+ c.inPorts.in.attach ins
+ c.outPorts.out.attach out
+ return [c, ins, out]
+
+exports['test encoding a string'] = (test) ->
+ [c, ins, out] = setupComponent()
+
+ out.on 'data', (data) ->
+ test.equals data, 'SGVsbG8sIFdvcmxkIQ=='
+ test.done()
+
+ ins.send 'Hello, World!'
+ ins.disconnect()
+
+exports['test encoding set of strings'] = (test) ->
+ [c, ins, out] = setupComponent()
+
+ out.on 'data', (data) ->
+ test.equals data, 'SGVsbG8sIFdvcmxkIQ=='
+ test.done()
+
+ ins.send 'Hello, '
+ ins.send 'World'
+ ins.send '!'
+ ins.disconnect()
+
+exports['test encoding a buffer'] = (test) ->
+ [c, ins, out] = setupComponent()
+
+ out.on 'data', (data) ->
+ test.equals data, 'SGVsbG8sIFdvcmxkIQ=='
+ test.done()
+
+ ins.send new Buffer 'Hello, World!'
+ ins.disconnect()

0 comments on commit 1780641

Please sign in to comment.