summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/async-some/test/simple.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/async-some/test/simple.js')
-rw-r--r--deps/npm/node_modules/async-some/test/simple.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/deps/npm/node_modules/async-some/test/simple.js b/deps/npm/node_modules/async-some/test/simple.js
new file mode 100644
index 000000000..3d68e1e50
--- /dev/null
+++ b/deps/npm/node_modules/async-some/test/simple.js
@@ -0,0 +1,60 @@
+var test = require("tap").test
+
+var some = require("../some.js")
+
+test("some() doesn't find anything asynchronously", function (t) {
+ some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.notOk(match, "nothing to find, so nothing found")
+
+ t.end()
+ })
+
+ function predicate(value, cb) {
+ // dezalgo ensures it's safe to not do this, but just in case
+ setTimeout(function () { cb(null, value > "j" && value) })
+ }
+})
+
+test("some() doesn't find anything synchronously", function (t) {
+ some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.notOk(match, "nothing to find, so nothing found")
+
+ t.end()
+ })
+
+ function predicate(value, cb) {
+ cb(null, value > "j" && value)
+ }
+})
+
+test("some() doesn't find anything asynchronously", function (t) {
+ some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.equals(match, "d", "found expected element")
+
+ t.end()
+ })
+
+ function predicate(value, cb) {
+ setTimeout(function () { cb(null, value > "c" && value) })
+ }
+})
+
+test("some() doesn't find anything synchronously", function (t) {
+ some(["a", "b", "c", "d", "e", "f", "g"], predicate, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.equals(match, "d", "found expected")
+
+ t.end()
+ })
+
+ function predicate(value, cb) {
+ cb(null, value > "c" && value)
+ }
+})