Commit 2861b1b202925df9274bc893cb07f9e3fec21734
update tests to include current directory
Dominic Tarr committed on 5/5/2013, 12:45:01 AMParent: 612300b7f69cb7091d65910dbba562118b78428a
Files changed
test/traversal.js | changed |
test/traversal.js | ||
---|---|---|
@@ -25,33 +25,38 @@ | ||
25 | 25 | }) |
26 | 26 | } |
27 | 27 | |
28 | 28 | test('widthFirst', function (t) { |
29 | - var max = 0 | |
29 | + var max = 0, didStart | |
30 | + | |
30 | 31 | ls_r(start, pull.widthFirst) |
31 | 32 | .pipe(pull.map(function (file) { |
33 | + if(file === start) didStart = true | |
32 | 34 | return file.split('/').length |
33 | 35 | })) |
34 | 36 | .pipe(pull.filter(function (d) { |
35 | 37 | t.ok(d >= max) |
36 | 38 | if(d > max) |
37 | 39 | return max = d, true |
38 | 40 | })) |
39 | 41 | .pipe(pull.through(console.log)) |
40 | - .pipe(pull.onEnd(function () { | |
41 | - t.end() | |
42 | + .pipe(pull.drain(null, function () { | |
43 | + t.ok(didStart) | |
44 | + t.end() | |
42 | 45 | })) |
43 | 46 | }) |
44 | 47 | |
45 | 48 | test('depthFirst', function (t) { |
46 | 49 | var seen = {} |
47 | - seen[start] = true | |
48 | 50 | //assert that for each item, |
49 | 51 | //you have seen the dir already |
50 | 52 | ls_r(start, pull.depthFirst) |
51 | 53 | .pipe(pull.through(function (file) { |
52 | - var dir = path.dirname(file) | |
53 | - t.ok(seen[dir]) | |
54 | + if(file != start) { | |
55 | + var dir = path.dirname(file) | |
56 | + t.ok(seen[dir]) | |
57 | + } | |
58 | + //console.log(dir) | |
54 | 59 | seen[file] = true |
55 | 60 | })) |
56 | 61 | .pipe(pull.onEnd(function () { |
57 | 62 | t.end() |
@@ -61,21 +66,22 @@ | ||
61 | 66 | |
62 | 67 | test('leafFirst', function (t) { |
63 | 68 | var seen = {} |
64 | 69 | var expected = {} |
65 | - // expected[start] = true | |
70 | + expected[start] = true | |
66 | 71 | //assert that for each item, |
67 | 72 | //you have seen the dir already |
68 | 73 | ls_r(start, pull.leafFirst) |
69 | 74 | .pipe(pull.through(function (file) { |
70 | - var dir = path.dirname(file) | |
71 | - t.ok(!seen[dir]) | |
72 | - expected[dir] = true | |
75 | + if(file !== start) { | |
76 | + var dir = path.dirname(file) | |
77 | + t.ok(!seen[dir]) | |
78 | + expected[dir] = true | |
79 | + } | |
73 | 80 | if(expected[file]) |
74 | 81 | delete expected[file] |
75 | 82 | })) |
76 | - .pipe(pull.onEnd(function () { | |
77 | - delete expected[start] | |
83 | + .pipe(pull.drain(null, function () { | |
78 | 84 | for(var k in expected) |
79 | 85 | t.ok(false, k) |
80 | 86 | t.end() |
81 | 87 | })) |
Built with git-ssb-web