Added the logic to handle when array is null.

This commit is contained in:
Ziang Song 2013-02-15 14:58:32 -05:00
commit 99cf4bfe01
2 changed files with 17 additions and 4 deletions

View file

@ -1,10 +1,10 @@
describe('Kiwi.compose', function() {
it('should return the empty when input is empty',function() {
it('should return the empty string when input is empty',function() {
var input = "";
expect(Kiwi.compose(input)).toEqual(input);
});
it('should return the input string',function() {
it('should return the input string when array is null',function() {
var input = "text without interpolation";
expect(Kiwi.compose(input)).toEqual(input);
});
@ -44,4 +44,10 @@ describe('Kiwi.compose', function() {
var result = "The rate is 2.3%";
expect(Kiwi.compose(input, ["rate"])).toEqual(result);
});
it('should add empty string when size of the array is larger than the placeholders.', function() {
var input = "The quick brown % jumps % the lazy %.";
var result = "The quick brown fox jumps over the lazy .";
expect(Kiwi.compose(input, ["fox", "over"])).toEqual(result);
});
});