Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

enhanced basic test to new collection methods

  • Loading branch information...
commit 3365779e46a83821a9d103ce19dd1faf72fe49dc 1 parent 6b8943f
@grob authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/collection_test.js
View
19 test/collection_test.js
@@ -98,15 +98,34 @@ exports.testBasics = function() {
var cnt = 0;
for each (var book in author.books) {
assert.isTrue(book instanceof Book);
+ assert.strictEqual(book._id, cnt + 1);
cnt += 1;
}
assert.strictEqual(cnt, author.books.length);
cnt = 0;
author.books.forEach(function(book, idx) {
assert.isTrue(book instanceof Book);
+ assert.strictEqual(book._id, cnt + 1);
cnt += 1;
});
assert.strictEqual(cnt, author.books.length);
+ // array methods
+ assert.strictEqual(author.books.indexOf(author.books.get(2)), 2);
+ assert.strictEqual(author.books.filter(function(book, idx) {
+ return book._id % 2 === 0;
+ }).length, 5);
+ assert.isTrue(author.books.some(function(book) {
+ return book._id === 5;
+ }));
+ assert.isTrue(author.books.every(function(book) {
+ return book instanceof Book;
+ }));
+ var ids = author.books.map(function(book) {
+ return book._id;
+ });
+ ids.forEach(function(id, idx) {
+ assert.strictEqual(id, idx + 1);
+ });
return;
};
Please sign in to comment.
Something went wrong with that request. Please try again.