Skip to content

Commit

Permalink
added: model.save tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emaphp committed Mar 15, 2015
1 parent d3e4224 commit 92c275d
Show file tree
Hide file tree
Showing 3 changed files with 429 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ contacts.fetch()
console.log('Collection fetched correctly');
})
.catch(function(data) {
console.log('Failed to fetch collection');
if (_.isError(data))
console.error(data)
else
console.log('Failed to fetch collection');
});
```

Expand All @@ -77,7 +80,10 @@ contact.fetch()
console.log('Contact fetched correctly');
})
.catch(function(data) {
console.log('Failed to fetch contact');
if (_.isError(data))
console.error(data)
else
console.log('Failed to fetch contact');
});
```

Expand Down
25 changes: 25 additions & 0 deletions test/specs/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,30 @@ describe("ASync.Collection tests", function() {

server.respond();
});

it('must throw error', function(done) {
server.respondWith(
'GET',
'/notes',
[
200,
null,
JSON.stringify([{id: 1}, {id: 2}, {id: 3}])
]
);

var notes = new FIXTURES.Notes();

notes.fetch()
.then(function(data) {
throw new Error();
})
.catch(function(err) {
expect(_.isError(err)).to.be.true;
done();
});

server.respond();
});
});
});
Loading

0 comments on commit 92c275d

Please sign in to comment.