--- a/test/underscore-methods.js Wed Dec 12 19:09:41 2012 +0900
+++ b/test/underscore-methods.js Wed Dec 12 19:41:08 2012 +0900
+// TODO: test sortedIndex
test('Underscore methods: basics', function() {
- equal(shard.first(), a, 'first() works');
- equal(shard.last(), c, 'last() works');
+ strictEqual(shard.first(), a, 'first() works');
+ strictEqual(shard.last(), c, 'last() works');
deepEqual(shard.initial(), [a, b], 'initial() works');
deepEqual(shard.rest(), [b, c], 'rest() works');
equal(shard.all(_.identity), true, 'all() works');
equal(shard.any(), true, 'any() works');
+ deepEqual(shard.sortBy(function(model) {
+ return -model.get('data').charCodeAt(0);
+ }), [c, b, a], 'sortBy() works');
+ deepEqual(shard.groupBy(function(model) {
+ return model.get('data').charCodeAt(0) % 2;
+ }), {0: [b], 1: [a, c]}, 'groupBy() works');
+ var sh = shard.shuffle().reduce(function(memo, model) { return memo += model.get('data'); }, '');
+ ok(sh.length == 3 && _(sh).contains('a') && _(sh).contains('b') && _(sh).contains('c'), 'shuffle() works');
test('Underscore methods: searching and filtering', function() {
- equal(shard.min(function(model) {
+ strictEqual(shard.min(function(model) {
return model.get('data').charCodeAt(0);
- equal(shard.max(function(model) {
+ strictEqual(shard.max(function(model) {
return model.get('data').charCodeAt(0);
- equal(shard.find(function(model) {
+ strictEqual(shard.find(function(model) {
return model.get('data') == 'b';