]> gerrit.simantics Code Review - simantics/district.git/blobdiff - 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
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/async-some/test/simple.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/async-some/test/simple.js
new file mode 100644 (file)
index 0000000..3d68e1e
--- /dev/null
@@ -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)
+  }
+})