source: trip-planner-front/node_modules/flatten/test.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 745 bytes
RevLine 
[6a3a178]1var flatten = require('./index'),
2 util = require('util'),
3 assert = require('assert');
4
5[
6 [ [1, [ 2, 3]], [1, [2, 3]], 0],
7 [ [1, 2, 3 ], [1, 2, 3] ],
8 [ ['a', ['b', ['c']]], ['a', 'b', 'c'] ],
9 [ [2, [4, 6], 8, [[10]]], [2, 4, 6, 8, 10] ],
10 [ [1, [2, [3, [4, [5]]]]], [1, 2, 3, [4, [5]]], 2 ] // depth of 2
11].forEach(function (t) {
12 assert.deepEqual(flatten(t[0], t[2]), t[1],
13 util.format('☠☠☠☠☠☠☠☠☠ %s ☠☠☠☠☠☠☠☠☠', formatCall(t))
14 );
15 console.log('✓ %s', formatCall(t));
16});
17
18function formatCall(t) {
19 if (typeof t[2] === 'undefined') {
20 return util.format('`flatten(%j) == %j`', t[0], t[1]);
21 }
22 else {
23 return util.format('`flatten(%j, %j) == %j`', t[0], t[2], t[1]);
24 }
25}
Note: See TracBrowser for help on using the repository browser.