Permalink
Browse files

test: remove "should" usage

Just use the built-in "assert" module instead.
  • Loading branch information...
1 parent 2e30730 commit 60c78a96a940053b3f4df4746fe40a29eb042268 @TooTallNate committed Nov 10, 2013
Showing with 37 additions and 38 deletions.
  1. +1 −2 package.json
  2. +4 −4 test/buffer.js
  3. +9 −9 test/callback.js
  4. +3 −3 test/create.js
  5. +20 −20 test/weakref.js
View
@@ -30,7 +30,6 @@
"bindings": "*"
},
"devDependencies": {
- "mocha": "> 0.7.0",
- "should": "*"
+ "mocha": "> 0.7.0"
}
}
View
@@ -1,4 +1,4 @@
-require('should')
+var assert = require('assert')
var weak = require('../')
describe('weak()', function () {
@@ -12,12 +12,12 @@ describe('weak()', function () {
var called = false
weak(Buffer('test'), function (buf) {
called = true
- buf.toString().should.equal('test')
+ assert.equal('test', buf.toString())
})
- called.should.be.false
+ assert(!called)
gc()
- called.should.be.true
+ assert(called)
})
})
View
@@ -1,4 +1,4 @@
-require('should')
+var assert = require('assert')
var weak = require('../')
describe('weak()', function () {
@@ -9,22 +9,22 @@ describe('weak()', function () {
it('should accept a function as second argument', function () {
var r = weak({}, function () {})
- weak.callbacks(r).should.have.lengthOf(1)
+ assert.equal(1, weak.callbacks(r).length)
})
it('should invoke the callback before the target is gc\'d', function () {
var called = false
weak({}, function () {
called = true
})
- called.should.equal.false
+ assert(!called)
gc()
- called.should.equal.true
+ assert(called)
})
it('should pass the target in as the first argument', function () {
weak({ foo: 'bar' }, function (o) {
- o.should.have.property('foo', 'bar')
+ assert.equal(o.foo, 'bar')
})
gc()
})
@@ -41,8 +41,8 @@ describe('weak()', function () {
called2 = true
})
gc()
- called1.should.equal.true
- called2.should.equal.true
+ assert(called1)
+ assert(called2)
})
})
@@ -53,8 +53,8 @@ describe('callbacks()', function () {
it('should return the Weakref\'s internal "callback" Array', function () {
var r = weak({})
, callbacks = weak.callbacks(r)
- callbacks.should.be.instanceof(Array)
- callbacks.should.have.lengthOf(0)
+ assert(Array.isArray(callbacks))
+ assert.equal(0, callbacks.length)
})
})
View
@@ -1,5 +1,5 @@
-var should = require('should')
- , weak = require('../')
+var assert = require('assert')
+var weak = require('../')
describe('create()', function () {
@@ -14,7 +14,7 @@ describe('create()', function () {
, undefined
, 'foo'
].forEach(function (val) {
- should.throws(function () {
+ assert.throws(function () {
weak.create(val)
})
})
View
@@ -1,4 +1,4 @@
-require('should')
+var assert = require('assert')
var weak = require('../')
describe('Weakref', function () {
@@ -7,73 +7,73 @@ describe('Weakref', function () {
it('weak() should return a `Weakref` instance', function () {
var ref = weak({})
- weak.isWeakRef(ref).should.be.true
+ assert(weak.isWeakRef(ref))
})
it('should proxy named gets to the target', function () {
var o = { foo: 'bar' }
, r = weak(o)
- r.should.have.property('foo', 'bar')
+ assert.equal(r.foo, 'bar')
})
it('should proxy named sets to the target', function () {
var o = {}
, r = weak(o)
r.foo = 'bar'
- o.should.have.property('foo', 'bar')
+ assert.equal(r.foo, 'bar')
})
it('should proxy named deletes to the target', function () {
var o = { foo: 'bar' }
, r = weak(o)
delete r.foo
- o.should.not.have.property('foo')
+ console.error(Object.getOwnPropertyNames(r));
+ assert(!('foo' in r))
})
it('should proxy indexed gets to the target', function () {
var a = [ 'foo' ]
, r = weak(a)
- a.should.have.lengthOf(1)
- r.should.have.lengthOf(1)
- r[0].should.equal('foo')
+ assert.equal(1, a.length)
+ assert.equal(1, r.length)
+ assert.equal('foo', r[0])
})
it('should proxy indexed sets to the target', function () {
var a = []
, r = weak(a)
- a.should.have.lengthOf(0)
- r.should.have.lengthOf(0)
+ assert.equal(0, a.length)
+ assert.equal(0, r.length)
r[0] = 'foo'
- a.should.have.lengthOf(1)
- a[0].should.equal('foo')
+ assert.equal(1, a.length)
+ assert.equal('foo', a[0])
r.push('bar')
- a.should.have.lengthOf(2)
- a[1].should.equal('bar')
+ assert.equal(2, a.length)
+ assert.equal('bar', a[1])
})
it('should proxy indexed deletes to the target', function () {
var a = [ 'foo' ]
, r = weak(a)
delete r[0]
- var t = typeof a[0]
- t.should.equal('undefined')
+ assert.equal('undefined', typeof a[0])
})
it('should proxy enumeration', function () {
var o = { a: 'a', b: 'b', c: 'c', d: 'd' }
, r = weak(o)
- r.should.have.keys(Object.keys(o))
+ assert.deepEquals(Object.keys(o), Object.keys(r))
})
it('should act like an empty object after target is gc\'d'
, function () {
var o = { foo: 'bar' }
, r = weak(o)
o = null
- r.should.have.property('foo', 'bar')
+ assert.equal('bar', r.foo)
gc()
- r.should.not.have.property('foo')
- Object.keys(r).should.have.lengthOf(0)
+ assert(!('foo' in r))
+ assert.equal(0,Object.keys(r).length)
})
})

0 comments on commit 60c78a9

Please sign in to comment.