diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-10-20 16:11:07 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-10-20 16:11:07 -0400 |
| commit | 5fc529464393b5bd078e6a3987e6198503a433ef (patch) | |
| tree | 2719b16dc4165e70cb7a9292eef224c3f74202cf /test/lib | |
| parent | 1928c62ffe255c3a2a89d31d7e8bf69035b1babb (diff) | |
test product apis
Diffstat (limited to 'test/lib')
| -rw-r--r-- | test/lib/promise.js | 21 | ||||
| -rw-r--r-- | test/lib/sdk.js | 9 |
2 files changed, 28 insertions, 2 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 diff --git a/test/lib/sdk.js b/test/lib/sdk.js index f1ae8f4c..1b922bd8 100644 --- a/test/lib/sdk.js +++ b/test/lib/sdk.js @@ -2,6 +2,11 @@ var najax = require('najax') var fs = require('fs') var path = require('path') +najax.defaults({ + rejectUnauthorized: false, + contentType: 'application/json', +}) + // hacky dummy jquery var $ = { ajax: najax, @@ -14,9 +19,9 @@ var files = "_sdk.js auth.js account.js address.js cart.js payment.js product.js for (var i = 0; i < files.length; i++) { var fn = path.join(__dirname, "../../StoneIsland/www/js/sdk/", files[i]) - console.log(fn) eval( fs.readFileSync(fn) + '' ) } -module.exports = sdk +sdk.init({ production: true }) +module.exports = sdk |
