This commit is contained in:
Ziang Song 2013-02-15 12:32:07 -05:00
commit c7d7c92522
7 changed files with 3368 additions and 0 deletions

42
spec/KiwiSpec.js Normal file
View file

@ -0,0 +1,42 @@
describe('Kiwi.compose', function() {
it('should return the input string',function() {
var input = "text without interpolation";
expect(Kiwi.compose(input)).toEqual(input);
});
it('should return replace %s with text', function() {
var input = "There are % apples";
var result = "There are five apples";
expect(Kiwi.compose(input, ["five"])).toEqual(result);
});
it('should return replace % with text when % is last', function() {
var input = "There are five %";
var result = "There are five apples";
expect(Kiwi.compose(input, ["apples"])).toEqual(result);
});
it('should return replace % when input is %', function() {
var input = "%";
var result = "There are five apples";
expect(Kiwi.compose(input, [result])).toEqual(result);
});
it('should return replace 2 %s when input has 2 %s', function() {
var input = "There are % %";
var result = "There are five apples";
expect(Kiwi.compose(input, ["five", "apples"])).toEqual(result);
});
it('should return replace 2 %s when input has 2 %s', function() {
var input = "% are % apples";
var result = "There are five apples";
expect(Kiwi.compose(input, ["There", "five"])).toEqual(result);
});
it('should return escaped %', function() {
var input = "The % is 2.3`%";
var result = "The rate is 2.3%";
expect(Kiwi.compose(input, ["rate"])).toEqual(result);
});
});