From 5fc529464393b5bd078e6a3987e6198503a433ef Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Oct 2015 16:11:07 -0400 Subject: test product apis --- test/lib/promise.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/lib/promise.js (limited to 'test/lib/promise.js') 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 -- cgit v1.2.3-70-g09d2