summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/async-some/test
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-09-24 14:41:07 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-09-24 17:15:10 -0700
commit9fad8958df671c0e894506ef59b4c781c3dfb349 (patch)
tree4db7643b40c4ffd726fb27fb4aa276d420b3bfd8 /deps/npm/node_modules/async-some/test
parentb26dd4e5ab9192bad72b9dc61fa4ad2d8f215da2 (diff)
downloadnode-new-9fad8958df671c0e894506ef59b4c781c3dfb349.tar.gz
deps: upgrade npm to 2.0.0
Diffstat (limited to 'deps/npm/node_modules/async-some/test')
-rw-r--r--deps/npm/node_modules/async-some/test/base-case.js35
-rw-r--r--deps/npm/node_modules/async-some/test/parameters.js37
-rw-r--r--deps/npm/node_modules/async-some/test/simple.js60
3 files changed, 132 insertions, 0 deletions
diff --git a/deps/npm/node_modules/async-some/test/base-case.js b/deps/npm/node_modules/async-some/test/base-case.js
new file mode 100644
index 0000000000..356890521d
--- /dev/null
+++ b/deps/npm/node_modules/async-some/test/base-case.js
@@ -0,0 +1,35 @@
+var test = require("tap").test
+
+var some = require("../some.js")
+
+test("some() array base case", function (t) {
+ some([], failer, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.notOk(match, "nothing to find, so nothing found")
+
+ t.end()
+ })
+
+ function failer(value, cb) {
+ cb(new Error("test should never have been called"))
+ }
+})
+
+test("some() arguments arraylike base case", function (t) {
+ go()
+
+ function go() {
+ some(arguments, failer, function (error, match) {
+ t.ifError(error, "ran successfully")
+
+ t.notOk(match, "nothing to find, so nothing found")
+
+ t.end()
+ })
+
+ function failer(value, cb) {
+ cb(new Error("test should never have been called"))
+ }
+ }
+})
diff --git a/deps/npm/node_modules/async-some/test/parameters.js b/deps/npm/node_modules/async-some/test/parameters.js
new file mode 100644
index 0000000000..0706d1da6f
--- /dev/null
+++ b/deps/npm/node_modules/async-some/test/parameters.js
@@ -0,0 +1,37 @@
+var test = require("tap").test
+
+var some = require("../some.js")
+
+var NOP = function () {}
+
+test("some() called with bogus parameters", function (t) {
+ t.throws(function () {
+ some()
+ }, "throws when called with no parameters")
+
+ t.throws(function () {
+ some(null, NOP, NOP)
+ }, "throws when called with no list")
+
+ t.throws(function () {
+ some([], null, NOP)
+ }, "throws when called with no predicate")
+
+ t.throws(function () {
+ some([], NOP, null)
+ }, "throws when called with no callback")
+
+ t.throws(function () {
+ some({}, NOP, NOP)
+ }, "throws when called with wrong list type")
+
+ t.throws(function () {
+ some([], "ham", NOP)
+ }, "throws when called with wrong test type")
+
+ t.throws(function () {
+ some([], NOP, "ham")
+ }, "throws when called with wrong test type")
+
+ t.end()
+})
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 0000000000..3d68e1e507
--- /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)
+ }
+})