diff options
| author | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
| commit | 686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch) | |
| tree | a5b5e50237cef70e12f0745371896e96f5f6d578 /node_modules/should/test/exist.test.js | |
ok
Diffstat (limited to 'node_modules/should/test/exist.test.js')
| -rw-r--r-- | node_modules/should/test/exist.test.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/node_modules/should/test/exist.test.js b/node_modules/should/test/exist.test.js new file mode 100644 index 0000000..7aa1082 --- /dev/null +++ b/node_modules/should/test/exist.test.js @@ -0,0 +1,96 @@ + +/** + * Module dependencies. + */ + +var should = require('../'); +var util = require('util'); + +function err(fn, msg) { + try { + fn(); + should.fail('expected an error'); + } catch (err) { + should.equal(msg, err.message); + } +} + +function err_should_exist(obj) { + err(function () { + should.exist(obj); + }, 'expected ' + util.inspect(obj) + ' to exist'); +} + +function err_should_not_exist(obj) { + err(function () { + should.not.exist(obj); + }, 'expected ' + util.inspect(obj) + ' to not exist'); +} + +module.exports = { + + // static should.exist() pass: + + 'test static should.exist() pass w/ bool': function () { + should.exist(false); + }, + + 'test static should.exist() pass w/ number': function () { + should.exist(0); + }, + + 'test static should.exist() pass w/ string': function () { + should.exist(''); + }, + + 'test static should.exist() pass w/ object': function () { + should.exist({}); + }, + + 'test static should.exist() pass w/ array': function () { + should.exist([]); + }, + + // static should.exist() fail: + + 'test static should.exist() fail w/ null': function () { + err_should_exist(null); + }, + + 'test static should.exist() fail w/ undefined': function () { + err_should_exist(undefined); + }, + + // static should.not.exist() pass: + + 'test static should.not.exist() pass w/ null': function () { + should.not.exist(null); + }, + + 'test static should.not.exist() pass w/ undefined': function () { + should.not.exist(undefined); + }, + + // static should.not.exist() fail: + + 'test static should.not.exist() fail w/ bool': function () { + err_should_not_exist(false); + }, + + 'test static should.not.exist() fail w/ number': function () { + err_should_not_exist(0); + }, + + 'test static should.not.exist() fail w/ string': function () { + err_should_not_exist(''); + }, + + 'test static should.not.exist() fail w/ object': function () { + err_should_not_exist({}); + }, + + 'test static should.not.exist() fail w/ array': function () { + err_should_not_exist([]); + }, + +}; |
