Commit 77e8971d09fb121162d025a7851aca84b3d5562f
Add test that fails when async-map is aborted while reading from an async source
Jan Bölsche authored on 4/23/2016, 10:33:53 AMDominic Tarr committed on 4/24/2016, 3:57:21 AM
Parent: fd5a385051c12f9b5331d8d77e51257f6d93bdc5
Files changed
test/async-map.js | changed |
test/async-map.js | ||
---|---|---|
@@ -41,8 +41,38 @@ | ||
41 | 41 | }) |
42 | 42 | |
43 | 43 | }) |
44 | 44 | |
45 | +tape('abort async map (async source)', function (t) { | |
46 | + var err = new Error('abort') | |
47 | + t.plan(2) | |
48 | + | |
49 | + var read = pull( | |
50 | + function(err, cb) { | |
51 | + setImmediate(function() { | |
52 | + if (err) return cb(err) | |
53 | + cb(null, 'x') | |
54 | + }) | |
55 | + }, | |
56 | + pull.asyncMap(function (data, cb) { | |
57 | + setImmediate(function () { | |
58 | + cb(null, data) | |
59 | + }) | |
60 | + }) | |
61 | + ) | |
62 | + | |
63 | + read(null, function (end) { | |
64 | + if(!end) throw new Error('expected read to end') | |
65 | + t.ok(end, "read's callback") | |
66 | + }) | |
67 | + | |
68 | + read(err, function (end) { | |
69 | + if(!end) throw new Error('expected abort to end') | |
70 | + t.ok(end, "Abort's callback") | |
71 | + t.end() | |
72 | + }) | |
73 | + | |
74 | +}) | |
45 | 75 | tape('asyncMap aborts when map errors', function (t) { |
46 | 76 | t.plan(2) |
47 | 77 | var ERR = new Error('abort') |
48 | 78 | pull( |
Built with git-ssb-web