spec/unit/array.spec.js in set_builder-2.0.0.beta2 vs spec/unit/array.spec.js in set_builder-2.0.0.beta3
- old
+ new
@@ -2,34 +2,34 @@
describe '.toSentence'
it 'should return an empty string if you pass a 0-length array'
expect([].toSentence()).to(be, '');
end
-
+
it 'should return the lone value if you pass a 1-length array'
expect(['banana'].toSentence()).to(be, 'banana');
end
-
+
it 'should concatenate only using "and" if you pass a 2-length array'
expect(['apple', 'banana'].toSentence()).to(be, 'apple and banana');
end
-
+
it 'should use different concatenators for a 3+-length array'
expect(['apple', 'banana', 'chocolate'].toSentence()).to(be, 'apple, banana, and chocolate');
end
end
-
+
describe '.dup'
it 'should create an independently modifiable array'
var a = [1, 2, 3];
var b = a.dup();
a.shift();
expect(a.length).to(be, 2);
expect(b.length).to(be, 3);
end
end
-
+
describe '.each'
it 'should correctly work through this array of arrays'
var i = 0;
[
['awesome'],
@@ -40,11 +40,11 @@
i += 1;
});
expect(i).to(be, 4);
end
end
-
+
describe '.inject'
it 'should count 4 objects in [12,32,12,11]'
expect([12,32,12,11].inject(0, function(i, item) {
return i + 1;
})).to(be, 4);
@@ -56,26 +56,26 @@
expect(["BIG", "ANGRY", "WORDS"].collect(function(word) {
return word.toLowerCase();
})).to(eql, ["big", "angry", "words"]);
end
end
-
+
describe '.find'
it 'should return the first word with an "a" in it'
expect(["not", "me", "what?", "me"].find(function(word) {
return /a/i.test(word);
})).to(be, "what?")
end
end
-
+
describe '.select'
it 'should return all members of the array where fn(member) is true'
expect(["this", "nope", "that", "this"].select(function(word){
return word == "this";
})).to(eql, ["this", "this"]);
end
end
-
+
end
describe 'Object'