]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/async-some/test/simple.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / async-some / test / simple.js
1 var test = require("tap").test
2
3 var some = require("../some.js")
4
5 test("some() doesn't find anything asynchronously", function (t) {
6   some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
7     t.ifError(error, "ran successfully")
8
9     t.notOk(match, "nothing to find, so nothing found")
10
11     t.end()
12   })
13
14   function predicate(value, cb) {
15     // dezalgo ensures it's safe to not do this, but just in case
16     setTimeout(function () { cb(null, value > "j" && value) })
17   }
18 })
19
20 test("some() doesn't find anything synchronously", function (t) {
21   some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
22     t.ifError(error, "ran successfully")
23
24     t.notOk(match, "nothing to find, so nothing found")
25
26     t.end()
27   })
28
29   function predicate(value, cb) {
30     cb(null, value > "j" && value)
31   }
32 })
33
34 test("some() doesn't find anything asynchronously", function (t) {
35   some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
36     t.ifError(error, "ran successfully")
37
38     t.equals(match, "d", "found expected element")
39
40     t.end()
41   })
42
43   function predicate(value, cb) {
44     setTimeout(function () { cb(null, value > "c" && value) })
45   }
46 })
47
48 test("some() doesn't find anything synchronously", function (t) {
49   some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
50     t.ifError(error, "ran successfully")
51
52     t.equals(match, "d", "found expected")
53
54     t.end()
55   })
56
57   function predicate(value, cb) {
58     cb(null, value > "c" && value)
59   }
60 })