git ssb

2+

Dominic / pull-stream



Commit 2861b1b202925df9274bc893cb07f9e3fec21734

update tests to include current directory

Dominic Tarr committed on 5/5/2013, 12:45:01 AM
Parent: 612300b7f69cb7091d65910dbba562118b78428a

Files changed

test/traversal.jschanged
test/traversal.jsView
@@ -25,33 +25,38 @@
2525 })
2626 }
2727
2828 test('widthFirst', function (t) {
29- var max = 0
29+ var max = 0, didStart
30+
3031 ls_r(start, pull.widthFirst)
3132 .pipe(pull.map(function (file) {
33+ if(file === start) didStart = true
3234 return file.split('/').length
3335 }))
3436 .pipe(pull.filter(function (d) {
3537 t.ok(d >= max)
3638 if(d > max)
3739 return max = d, true
3840 }))
3941 .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()
4245 }))
4346 })
4447
4548 test('depthFirst', function (t) {
4649 var seen = {}
47- seen[start] = true
4850 //assert that for each item,
4951 //you have seen the dir already
5052 ls_r(start, pull.depthFirst)
5153 .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)
5459 seen[file] = true
5560 }))
5661 .pipe(pull.onEnd(function () {
5762 t.end()
@@ -61,21 +66,22 @@
6166
6267 test('leafFirst', function (t) {
6368 var seen = {}
6469 var expected = {}
65- // expected[start] = true
70+ expected[start] = true
6671 //assert that for each item,
6772 //you have seen the dir already
6873 ls_r(start, pull.leafFirst)
6974 .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+ }
7380 if(expected[file])
7481 delete expected[file]
7582 }))
76- .pipe(pull.onEnd(function () {
77- delete expected[start]
83+ .pipe(pull.drain(null, function () {
7884 for(var k in expected)
7985 t.ok(false, k)
8086 t.end()
8187 }))

Built with git-ssb-web