UNPKG

892 BJavaScriptView Raw
1'use strict';
2
3var falafel = require('falafel');
4var test = require('../');
5
6test('nested array test', function (t) {
7 t.plan(5);
8
9 var src = '(' + function () {
10 var xs = [1, 2, [3, 4]];
11 var ys = [5, 6];
12 g([ xs, ys ]);
13 } + ')()';
14
15 var output = falafel(src, function (node) {
16 if (node.type === 'ArrayExpression') {
17 node.update('fn(' + node.source() + ')');
18 }
19 });
20
21 t.test('inside test', function (q) {
22 q.plan(2);
23 q.ok(true, 'inside ok');
24
25 setTimeout(function () {
26 q.ok(true, 'inside delayed');
27 }, 3000);
28 });
29
30 var arrays = [
31 [3, 4],
32 [1, 2, [3, 4]],
33 [5, 6],
34 [[ 1, 2, [3, 4]], [5, 6]]
35 ];
36
37 Function(['fn', 'g'], output)(
38 function (xs) {
39 t.same(arrays.shift(), xs);
40 return xs;
41 },
42 function (xs) {
43 t.same(xs, [[1, 2, [3, 4]], [5, 6]]);
44 }
45 );
46});
47
48test('another', function (t) {
49 t.plan(1);
50 setTimeout(function () {
51 t.ok(true);
52 }, 100);
53});