-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split tests into separate files by topic
- Loading branch information
1 parent
ca674d9
commit dc83194
Showing
12 changed files
with
190 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe('#gsub', function() { | ||
describe('with a regex', function() { | ||
it('replaces one instance of the match', function() { | ||
expect(_.gsub('word', /wo/, 'ne')).to.equal('nerd'); | ||
}); | ||
it('replaces two instances of the match', function() { | ||
expect(_.gsub('word word', /wo/, 'ne')).to.equal('nerd nerd'); | ||
}); | ||
it('returns null if no match', function() { | ||
expect(_.gsub('word', /zz/, 'ne')).to.be.null; | ||
}); | ||
}); | ||
describe('with a string', function() { | ||
it('replaces one instance of the match', function() { | ||
expect(_.gsub('word', 'wo', 'ne')).to.equal('nerd'); | ||
}); | ||
it('replaces two instances of the match', function() { | ||
expect(_.gsub('word word', 'wo', 'ne')).to.equal('nerd nerd'); | ||
}); | ||
it('returns null if no match', function() { | ||
expect(_.gsub('word', 'zz', 'ne')).to.be.null; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
describe('#irregular', function() { | ||
it('adds a rule to pluralize the special case', function() { | ||
_.irregular('haxor', 'hax0rs!'); | ||
expect(_.pluralize('haxor')).to.equal('hax0rs!'); | ||
}); | ||
it('adds a rule to singularize the special case', function() { | ||
_.irregular('hax0r!', 'haxors'); | ||
expect(_.singularize('haxors')).to.equal('hax0r!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
describe('#ordinalize', function() { | ||
it('returns a stirng that is not a number or string', function() { | ||
expect(_.ordinalize('hello')).to.equal('hello'); | ||
}); | ||
it('ordinalizes a number', function() { | ||
expect(_.ordinalize(4)).to.equal('4th'); | ||
}); | ||
it('ordinalizes a number string', function() { | ||
expect(_.ordinalize('4')).to.equal('4th'); | ||
}); | ||
it('ordinalizes 0 to "0th"', function() { | ||
expect(_.ordinalize(0)).to.equal('0th'); | ||
}); | ||
it('ordinalizes 1 to "1st"', function() { | ||
expect(_.ordinalize(1)).to.equal('1st'); | ||
}); | ||
it('ordinalizes 2 to "2nd', function() { | ||
expect(_.ordinalize(2)).to.equal('2nd'); | ||
}); | ||
it('ordinalizes 3 to "3rd"', function() { | ||
expect(_.ordinalize(3)).to.equal('3rd'); | ||
}); | ||
it('ordinalizes 11 to "11th"', function() { | ||
expect(_.ordinalize(11)).to.equal('11th'); | ||
}); | ||
it('ordinalizes 12 to "12th"', function() { | ||
expect(_.ordinalize(12)).to.equal('12th'); | ||
}); | ||
it('ordinalizes 13 to "13th"', function() { | ||
expect(_.ordinalize(13)).to.equal('13th'); | ||
}); | ||
it('ordinalizes 1003 to "1003rd"', function() { | ||
expect(_.ordinalize(1003)).to.equal('1003rd'); | ||
}); | ||
it('ordinalizes -11 to "-11th', function() { | ||
expect(_.ordinalize(-11)).to.equal('-11th'); | ||
}); | ||
it('ordinalizes -1021 to "-1021st', function() { | ||
expect(_.ordinalize(-1021)).to.equal('-1021st'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
describe('#plural', function() { | ||
it('adds a new pluralization rule by explict string', function() { | ||
_.plural('axis', 'axes'); | ||
expect(_.pluralize('axis')).to.equal('axes'); | ||
}); | ||
it('adds a new pluralization rule by regex', function() { | ||
_.plural(/(ax)is$/i, '$1es'); | ||
expect(_.pluralize('axis')).to.equal('axes'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe('#pluralize', function() { | ||
it('pluralizes the given noun', function() { | ||
expect(_.pluralize('post')).to.equal('posts'); | ||
}); | ||
it('returns the same word if it cannot be pluralized', function() { | ||
expect(_.pluralize('posts')).to.equal('posts'); | ||
}); | ||
describe('with a number', function() { | ||
it('pluralizes the word if not 1', function() { | ||
expect(_.pluralize('post', 0)).to.equal('posts'); | ||
}); | ||
it('pluralizes the word if not "1"', function() { | ||
expect(_.pluralize('post', '0')).to.equal('posts'); | ||
}); | ||
it('pluralizes the word if non-1 float', function() { | ||
expect(_.pluralize('post', 1.5)).to.equal('posts'); | ||
}); | ||
it('singularizes the word if 1', function() { | ||
expect(_.pluralize('posts', 1)).to.equal('post'); | ||
}); | ||
it('singularizes the word if "1"', function() { | ||
expect(_.pluralize('posts', '1')).to.equal('post'); | ||
}); | ||
describe('and true', function() { | ||
it('includes the word with the plural', function() { | ||
expect(_.pluralize('post', 0, true)).to.equal('0 posts'); | ||
}); | ||
it('includes the word with non-1 float', function() { | ||
expect(_.pluralize('post', '1.3', true)).to.equal('1.3 posts'); | ||
}); | ||
it('includes the word with the singular', function() { | ||
expect(_.pluralize('post', 1, true)).to.equal('1 post'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
describe('#singular', function() { | ||
it('adds a new singularization rule by explicit string', function() { | ||
_.singular('data', 'datum'); | ||
expect(_.singularize('data')).to.equal('datum'); | ||
}); | ||
it('adds a new singularization rule by regex', function() { | ||
_.singular(/(t)a$/i, '$1um'); | ||
expect(_.singularize('data')).to.equal('datum'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('#singularize', function() { | ||
it('singularizes the given noun', function() { | ||
expect(_.singularize('posts')).to.equal('post'); | ||
}); | ||
it('returns the same word if it cannot be singularized', function() { | ||
expect(_.singularize('post')).to.equal('post'); | ||
}); | ||
it('singularizes a word that contains an irregular', function() { | ||
expect(_.singularize('comments')).to.equal('comment'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe('#titleize', function() { | ||
it('returns non-strings', function() { | ||
expect(_.titleize(5)).to.equal(5); | ||
}); | ||
it('returns the empty string when provided with the empty string', function() { | ||
expect(_.titleize('')).to.equal(''); | ||
}); | ||
it('titleizes a word', function() { | ||
expect(_.titleize('banana')).to.equal('Banana'); | ||
}); | ||
it('titleizes multiple words', function() { | ||
expect(_.titleize('banana potato fork')).to.equal('Banana Potato Fork'); | ||
}); | ||
it('does not change the whitespace', function() { | ||
expect(_.titleize('\tbanana\npotato fork\r\n')).to.equal('\tBanana\nPotato Fork\r\n'); | ||
}); | ||
it('does not alter words that begin with non-alphabetic characters', function() { | ||
expect(_.titleize('123banana')).to.equal('123banana'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
describe('#uncountable', function() { | ||
it('notes the word as a special case in pluralization', function() { | ||
_.uncountable('asdf'); | ||
expect(_.pluralize('asdf')).to.equal('asdf'); | ||
}); | ||
it('notes the word as a special case in singularization', function() { | ||
_.uncountable('asdf'); | ||
expect(_.singularize('asdf')).to.equal('asdf'); | ||
}); | ||
}); |