Skip to content

Commit

Permalink
use promise terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
twalker committed Jun 14, 2014
1 parent eda8828 commit 398a869
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 50 deletions.
42 changes: 1 addition & 41 deletions public/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/js/src/models/mixins/fetch-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* });
*
* TODO:
* - return more useful error
* - If using backbone-promises, we don't need to cast jQuery Deferred with Promise.resolve.
*
**/
define(function(require){
Expand Down
16 changes: 8 additions & 8 deletions public/js/test/backbone-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require([
mocha.setup('bdd');

// re-define Backbone ajax
describe('backbone-promises monkey patches a few Backbone pains', function() {
describe('`backbone-promises` monkey patches Backbone sync operations to return ES6 promises', function() {
var server;
beforeEach(function(){
server = sinon.fakeServer.create();
Expand Down Expand Up @@ -43,22 +43,22 @@ require([
url: '/testmodel',
});

it('should pass the model/collection as the argument promise resolutions', function(done){
it('should pass the model/collection to promise fulfillments', function(done){
var testattr = {id:1, name: 'foo'};
var loadSpy = sinon.spy(),
successSpy = sinon.spy();

var m = new TestModel();

m
.save({name: "foo"})
.save({name: 'foo'})
.then(function(model){
assert.strictEqual(model, m);
})
.then(function(){
m.save({name: "updated foo"})
m.save({name: 'updated foo'})
.then(function(model){
assert.equal(model.get('name'), "updated foo");
assert.equal(model.get('name'), 'updated foo');
})
})
.then(function(){
Expand All @@ -81,7 +81,7 @@ require([
]);
});

it('should return the xhr object to rejections', function(done){
it('should pass the xhr object to promise rejections', function(done){
var m = new TestModel();
m
.save({name: 'foo'}, {url:'/testmodel'})
Expand All @@ -107,7 +107,7 @@ require([
}
});

it('should reject promise with xhr when xhr fails', function(done){
it('should reject promise when xhr fails', function(done){
var m = new TestModel();
m.save({name: 'broken'}, {wait: true, validate: false}).catch(function(xhr){
assert.equal(xhr.status, 500);
Expand All @@ -119,7 +119,7 @@ require([
]);
});

it('should still emit `invalid` events and not sync when validation fails', function(done){
it('should still emit `invalid` event when validation fails, but now return rejected promise with model instead of false', function(done){
var m = new TestModel({name: 'foo'});
m.on('invalid', function(err){
done();
Expand Down

0 comments on commit 398a869

Please sign in to comment.