UNPKG

726 BJavaScriptView Raw
1var assert = require('assert')
2 , chai = require('chai')
3 , dg = require( '../lib/dg.js' );
4
5var input = [ 'test', 'another test', 1234, 'a string' ];
6
7it('in', function () {
8 var r = dg.in( input, 'a string' );
9 assert( r, 'returned truth' );
10 var s = dg.in( input, 'peace on earth' );
11 chai.assert.notOk( s, 'returned false (boo-hoo)' );
12} );
13
14it('all_in', function () {
15 var r = dg.all_in( input, [ 'a string', 'test' ] );
16 assert(r, 'truth returned');
17
18 // We do not guarantee the return order of lists. Chai has this cool 'equal-ish' assert:
19 // .include(haystack, needle, [message])
20 //
21
22 r.forEach( function (test) {
23 chai.assert.include( [ 'a string', 'test' ], test, 'correct values returned' );
24 } );
25} );