Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var buster = require('buster-node');
var util = require('../../lib/api/util');
var referee = require('referee');
var text = require('bagoftext');
var assert = referee.assert;
text.setLocale('en');
buster.testCase('api - util', {
setUp: function () {
this.mock({});
},
'passThroughResponse - should pass entire response': function (done) {
function cb(err, result) {
assert.isNull(err);
assert.equals(result, 'someresponse');
done();
}
util.passThroughResponse('someresponse', cb);
},
'passThroughSuccess - should pass result body': function (done) {
function cb(err, result) {
assert.isNull(err);
assert.equals(result, 'somebody');
done();
shows: {}
}
]
},
function (err, result) {
assert.equals(err, null);
assert.isTrue(!_.isEmpty(result));
assert.isTrue(result[0][4].ok);
done();
});
}
});
buster.testCase('db - _handle', {
setUp: function () {
this.mock({});
this.db = new Db('http://localhost:5984', { nano: function (url) {} });
},
'should return result object when there is no error': function (done) {
function _cb(err, result) {
assert.isNull(err);
assert.equals(result.id, 'db1/doc1');
assert.equals(result.message, 'created');
done();
}
this.db._handle(_cb, { dbName: 'db1', docId: 'doc1', message: 'created' })();
},
'should delegate to optional success callback when there is no error and success callback is specified': function (done) {
function _successCb(err, result) {
assert.isNull(err);