Comparing version 0.1.0 to 0.1.1
@@ -0,1 +1,5 @@ | ||
# 0.1.1 (2014-10-30) | ||
* allow for extra response option from sync for .find | ||
# 0.1.0 (2014-10-26) | ||
@@ -2,0 +6,0 @@ |
@@ -381,3 +381,3 @@ var Emitter = require('emitter'); | ||
sync(sync_opt, function(err, result) { | ||
sync(sync_opt, function(err, result, response) { | ||
if (err) { | ||
@@ -387,3 +387,3 @@ return cb(err); | ||
return cb(null, result.map(Construct)); | ||
return cb(null, result.map(Construct), response); | ||
}); | ||
@@ -390,0 +390,0 @@ }; |
{ | ||
"name": "bamboo", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Roman Shtylman <shtylman@gmail.com>", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -50,2 +50,23 @@ var assert = require('assert'); | ||
test('should update on fetch', function(done) { | ||
function sync(opt, cb) { | ||
assert.equal(opt.method, 'GET'); | ||
assert.equal(opt.url, '/posts/12345'); | ||
assert.equal(opt.query, undefined); | ||
cb(null, { | ||
title: 'hello world' | ||
}); | ||
}; | ||
var post = Post.extend({}, { sync: sync })(); | ||
post.id = '12345'; | ||
post.title = 'test'; | ||
post.fetch(function(err) { | ||
assert.ifError(err); | ||
assert.equal(post.id, 12345); | ||
assert.equal(post.title, 'hello world'); | ||
done(); | ||
}); | ||
}); | ||
test('destroy', function(done) { | ||
@@ -76,1 +97,32 @@ function sync(opt, cb) { | ||
}) | ||
test('should pass the response back for .find', function(done) { | ||
function sync(opt, cb) { | ||
assert.equal(opt.method, 'GET'); | ||
assert.equal(opt.url, '/posts'); | ||
var posts = [{ | ||
id: '1', | ||
title: 'Hello World' | ||
}, { | ||
id: '2', | ||
title: 'Magic Beans' | ||
}]; | ||
var res = { | ||
body: posts, | ||
headers: { | ||
foo: 'bar' | ||
} | ||
} | ||
cb(null, posts, res); | ||
}; | ||
var NewPost = Post.extend({}, { sync: sync }); | ||
NewPost.find(function(err, posts, res) { | ||
assert.ifError(err); | ||
assert.equal(posts.length, 2); | ||
done(); | ||
}); | ||
}); |
32108
796