Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add basic test for ChunkReverser

  • Loading branch information...
commit bb9d76e1bb1540ea3e5173aebc92732a9d503257 1 parent 7a63246
@rvagg rvagg authored
View
2  .gitignore
@@ -1,2 +1,4 @@
/data.in
/data.out
+node_modules/
+npm-debug.log
View
7 buster.js
@@ -0,0 +1,7 @@
+var config = module.exports
+
+config['unit'] = {
+ environment: 'node'
+ , tests: [ 'test/*-test.js' ]
+ , libs: [ 'test/common.js' ]
+}
View
7 package.json
@@ -16,6 +16,13 @@
"pipe",
"wrapper"
],
+ "devDependencies": {
+ "buster": "*",
+ "concat-stream": "*"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/buster-test"
+ },
"author": "Conrad Pankoff <deoxxa@fknsrs.biz> (http://www.fknsrs.biz/)",
"license": "BSD"
}
View
47 test/chunk-reverser-test.js
@@ -0,0 +1,47 @@
+var buster = require('buster')
+ , concatStream = require('concat-stream')
+ , fs = require('fs')
+ , util = require('util')
+
+ , assert = buster.assert
+ , Steez = require('../')
+
+function ChunkReverser() {
+ Steez.call(this)
+}
+
+util.inherits(ChunkReverser, Steez)
+
+ChunkReverser.prototype.write = function write(data) {
+ this.emit('data', Buffer(data.toString().split('').reverse().join('')))
+
+ return !this.paused && this.writable
+}
+
+// uses `fs.createReadStream()` as a reference Stream implementation
+
+buster.testCase('ChunkReverser', {
+ 'setUp': function (done) {
+ this.bogan = "She'll be right pozzy no worries stands out like a dunny. Lets get some blowie also rotten. spag bol as cunning as a ugg boots. Trent from punchy vinnie's piece of piss lets get some metho. Come a dunny where you little ripper piker. You little ripper galah no dramas he hasn't got a true blue."
+ this.file = '$$_chunkReverserTest_$$'
+ fs.writeFile(this.file, this.bogan, done)
+ }
+
+ , 'tearDown': function (done) {
+ fs.unlink(this.file, done)
+ }
+
+ , 'test basic ChunkReverser': function (done) {
+ var collector = concatStream(function(err, data) {})
+ , inStream = fs.createReadStream(this.file)
+ , expected = this.bogan.split('').reverse().join('')
+
+ , verify = function () {
+ assert.equals(collector.getBody().toString(), expected)
+ done()
+ }.bind(this)
+
+ inStream.pipe(new ChunkReverser()).pipe(collector)
+ inStream.on('end', verify)
+ }
+})
View
0  test/common.js
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.