1 | 'use strict';
|
2 |
|
3 | var assert = require( 'assert' )
|
4 | , chai = require( 'chai' )
|
5 | , dg = require( '../lib/dg' )
|
6 |
|
7 | , nested_list = function () { return [ 'foo', [ 'unicorn', 'bar', [ 'leprechaun' ] ], 'baz' ] }
|
8 |
|
9 | , mythical = function () { [ 'unicorn', 'leprechaun', 'griffin', 'sphinx', 'centaur', 'dragon', 'siren', 'banshee' ] }
|
10 |
|
11 | it( 'nested list', function () {
|
12 |
|
13 | assert( function () {
|
14 | var uni = dg.deeply(
|
15 | nested_list(),
|
16 | function (t) { if (t == 'unicorn') return true }
|
17 | );
|
18 | if (uni.length != 1) { return false; }
|
19 | if (uni[0] != 'unicorn') { return false; }
|
20 | return true;
|
21 | }, 'returns requisite element' );
|
22 |
|
23 | var test = function (t) {
|
24 | if ( (t == 'unicorn') || (t == 'leprechaun') ) {
|
25 | return true;
|
26 | }
|
27 | return false;
|
28 | }
|
29 |
|
30 | var pair = dg.deeply( nested_list(), test );
|
31 |
|
32 | assert(pair.length == 2, 'two elements returned');
|
33 |
|
34 | } );
|