This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit shameful to not have these. diff --git a/test/assert.js b/test/assert.js new file mode 100644 index 0000000..0ebdab4 --- /dev/null +++ b/test/assert.js @@ -0,0 +1,52 @@ +var expect = require('chai').expect + , assert = require('../lib/assert') + , each = require('../lib/each') + , src = require('../lib/src') + , $ = require('../lib/partial') + +describe('assert', function() { + each( + [ null + , false + , undefined + ] + , + function(x) { + describe('when given `' + src(x) + '`', function() { + it('should throw an error with the message `Assertion failed.`', function() { + expect($(assert, x)).to.throw('Assertion failed.') + }) + + describe('and also given the message `:o(`', function() { + it('should throw an error with the message `:o(`', function() { + expect($(assert, x, ':o(')).to.throw(':o(') + }) + }) + + describe('and also given an instance of Error', function() { + it('should throw that error', function() { + var err = new Error('sad face') + expect($(assert, x, err)).to.throw(err) + }) + }) + }) + } + ) + + each( + [ 0 + , '' + , {} + , [] + ] + , + function(x) { + describe('when given `' + src(x) + '`', function() { + it('should not throw an error and return the value', function() { + expect($(assert, x)).to.not.throw + expect(assert(x)).to.equal(x) + }) + }) + } + ) +}) \ No newline at end of file
- Loading branch information