summaryrefslogtreecommitdiff
path: root/test/lib/promise.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/promise.js')
-rw-r--r--test/lib/promise.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/lib/promise.js b/test/lib/promise.js
new file mode 100644
index 00000000..d2afe09c
--- /dev/null
+++ b/test/lib/promise.js
@@ -0,0 +1,21 @@
+module.exports = function(fn, data){
+ var my_cb, my_res
+ data.success = function(res){
+ my_res = res
+ if (my_cb) {
+ my_cb(res)
+ }
+ }
+ data.error = function(res){
+ console.log('error!')
+ console.log(res)
+ }
+ fn(data)
+ var promise = {
+ then: function(cb){
+ if (my_res) cb(my_res)
+ else my_cb = cb
+ }
+ }
+ return promise
+} \ No newline at end of file