Skip to content

Commit

Permalink
[test] Add tests for the some more sync hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt authored and Marak committed Jul 17, 2012
1 parent e46ed2d commit ad17c52
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions test/hooks-sync-test.js
Expand Up @@ -65,12 +65,18 @@ vows.describe('resourceful/hooks/sync').addBatch({
},
"when calling save() on an instance of Article": {
topic: function (R) {
new(R)({ id: '678', counter: 0, title: 'a-name2' }).save(this.callback);
var self = this;
new(R)({ id: '678', counter: 0, title: 'a-name2' }).save(function(e, i) {
R.get('678', function(err, res) {
self.callback(e, i, res);
});
});
},
"should trigger both hooks in the right order": function (e, res) {
"should trigger both hooks in the right order": function (e, res, i) {
assert.isNull(e);
assert.equal(this.run, 4);
assert.equal(res.counter, 4);
assert.equal(i.counter, 0);
}
}
}
Expand Down Expand Up @@ -149,12 +155,19 @@ vows.describe('resourceful/hooks/sync').addBatch({
},
"when calling create() on an instance of Article": {
topic: function (R) {
R.create({ id: '67', counter: 0, title: 'hookbar' }, this.callback);
var self = this;
R.create({ id: '67', counter: 0, title: 'hookbar' }, function(e, i) {
R.get('67', function(err, res) {
self.callback(e, i, res);
});
});
},
"should trigger both hooks in the right order": function (e, res) {
"should trigger both hooks in the right order": function (e, res, i) {
assert.isNull(e);
assert.equal(this.save, 4);
assert.equal(this.create, 4);
assert.equal(i.counter, 4);
assert.equal(res.counter, 12);
}
}
}
Expand Down

0 comments on commit ad17c52

Please sign in to comment.