summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/promise.js16
-rw-r--r--test/lib/sdk.js1
2 files changed, 14 insertions, 3 deletions
diff --git a/test/lib/promise.js b/test/lib/promise.js
index d2afe09c..ad895d90 100644
--- a/test/lib/promise.js
+++ b/test/lib/promise.js
@@ -1,5 +1,5 @@
module.exports = function(fn, data){
- var my_cb, my_res
+ var my_cb, my_res, error_cb, my_error
data.success = function(res){
my_res = res
if (my_cb) {
@@ -7,14 +7,24 @@ module.exports = function(fn, data){
}
}
data.error = function(res){
- console.log('error!')
- console.log(res)
+ my_error = res
+ if (error_cb) {
+ error_cb(res)
+ }
+ else {
+ console.log('error!')
+ console.log(res)
+ }
}
fn(data)
var promise = {
then: function(cb){
if (my_res) cb(my_res)
else my_cb = cb
+ },
+ error: function(cb){
+ if (my_error) cb(my_error)
+ else error_cb = cb
}
}
return promise
diff --git a/test/lib/sdk.js b/test/lib/sdk.js
index 1b922bd8..4ebffb8b 100644
--- a/test/lib/sdk.js
+++ b/test/lib/sdk.js
@@ -5,6 +5,7 @@ var path = require('path')
najax.defaults({
rejectUnauthorized: false,
contentType: 'application/json',
+ dataType: 'json',
})
// hacky dummy jquery