-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Refactor tests (closes #103)
- Loading branch information
Showing
9 changed files
with
263 additions
and
166 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
'use strict'; | ||
|
||
var expect = require('expect'); | ||
|
||
var cloneBuffer = require('../lib/cloneBuffer'); | ||
var should = require('should'); | ||
require('mocha'); | ||
|
||
describe('cloneBuffer()', function() { | ||
it('should return a new Buffer reference', function(done) { | ||
|
||
it('returns a new Buffer reference', function(done) { | ||
var testBuffer = new Buffer('test'); | ||
var testBuffer2 = cloneBuffer(testBuffer); | ||
|
||
should.exist(testBuffer2, 'should return something'); | ||
(testBuffer2 instanceof Buffer).should.equal(true, 'should return a Buffer'); | ||
testBuffer2.should.not.equal(testBuffer, 'pointer should change'); | ||
expect(testBuffer2).toExist(); | ||
expect(testBuffer2).toBeA(Buffer); | ||
expect(testBuffer2).toNotEqual(testBuffer); | ||
done(); | ||
}); | ||
|
||
it('should not replicate modifications to the original buffer', function(done) { | ||
it('does not replicate modifications to the original Buffer', function(done) { | ||
var testBuffer = new Buffer('test'); | ||
var testBuffer2 = cloneBuffer(testBuffer); | ||
|
||
// Test that changes dont modify both pointers | ||
testBuffer2.write('w'); | ||
|
||
testBuffer.toString('utf8').should.equal('test', 'original should stay the same'); | ||
testBuffer2.toString('utf8').should.equal('west', 'new buffer should be modified'); | ||
expect(testBuffer.toString('utf8')).toEqual('test'); | ||
expect(testBuffer2.toString('utf8')).toEqual('west'); | ||
done(); | ||
}); | ||
}); |
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
Oops, something went wrong.