Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Aug 3, 2012
1 parent dd51985 commit ef4f933
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 32 deletions.
23 changes: 8 additions & 15 deletions test/inflection.en.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ var lingo = require('./..')
, en = lingo.en;

module.exports = {
'test .name': function(assert){
'test .name': function(){
assert.equal('English', en.name);
},

'test .isUncountable()': function(assert){
'test .isUncountable()': function(){
assert.equal(true, en.isUncountable('moose'));
assert.equal(false, en.isUncountable('person'));
},

'test .uncountable()': function(assert){
'test .uncountable()': function(){
delete en.rules.uncountable.foobar;
assert.equal(false, en.isUncountable('foobar'));
en.uncountable('foobar');
assert.equal(true, en.isUncountable('foobar'));
},

'test .pluralNumbers()': function(assert){
'test .pluralNumbers()': function(){
delete en.rules.pluralNumbers;
assert.equal(true, en.isPlural(1));
en.pluralNumbers(/[^1]/);
assert.equal(false, en.isPlural(1));
},

'test .pluralize()': function(assert){
'test .pluralize()': function(){
assert.equal('ids', en.pluralize('id'));
assert.equal('friends', en.pluralize('friend'));
assert.equal('buses', en.pluralize('bus'));
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = {
assert.equal('categories', en.pluralize('category'));
},

'test .singularize()': function(assert){
'test .singularize()': function(){
assert.equal('paper', en.singularize('paper'));
assert.equal('ox', en.singularize('oxen'));
assert.equal('shoe', en.singularize('shoes'));
Expand All @@ -100,26 +100,19 @@ module.exports = {
assert.equal('series', en.singularize('series'));
},

'test .isPlural()': function(assert){
'test .isPlural()': function(){
assert.equal(true, en.isPlural('dogs'));
assert.equal(true, en.isPlural('monkies'));
assert.equal(true, en.isPlural('foxes'));
assert.equal(false, en.isPlural('key'));
assert.equal(false, en.isPlural('fox'));
},

'test .isSingular()': function(assert){
'test .isSingular()': function(){
assert.equal(true, en.isSingular('fox'));
assert.equal(true, en.isSingular('person'));
assert.equal(true, en.isSingular('dog'));
assert.equal(false, en.isSingular('keys'));
assert.equal(false, en.isSingular('foxes'));
},

'test .tabelize()': function(assert){
assert.equal('user_accounts', en.tabelize('UserAccount'));
assert.equal('user', en.tabelize('User'));
assert.equal('monkeys', en.tabelize('Monkey'));
assert.equal('animals', en.tabelize('Animal'));
}
};
12 changes: 6 additions & 6 deletions test/inflection.es.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ var lingo = require('./..')
, es = lingo.es;

module.exports = {
'test .isUncountable()': function(assert){
'test .isUncountable()': function(){
assert.equal(true, es.isUncountable('agua'));
assert.equal(false, es.isUncountable('arbol'));
},

'test .pluralNumbers()': function(assert){
'test .pluralNumbers()': function(){
delete es.rules.pluralNumbers;
assert.equal(true, es.isPlural(1));
es.pluralNumbers(/[^1]/);
assert.equal(false, es.isPlural(1));
},

'test .pluralize()': function(assert){
'test .pluralize()': function(){
assert.equal('perros', es.pluralize('perro'));
assert.equal('arboles', es.pluralize('arbol'));
assert.equal('cojones', es.pluralize('cojón'));
assert.equal('androides', es.pluralize('androide'));
},

'test .singularize()': function(assert){
'test .singularize()': function(){
assert.equal('perro', es.singularize('perros'));
assert.equal('árbol', es.singularize('árboles'));
assert.equal('cojón', es.singularize('cojones'));
assert.equal('androide', es.singularize('androides'));
},

'test .isPlural()': function(assert){
'test .isPlural()': function(){
assert.equal(true, es.isPlural('perros'));
assert.equal(true, es.isPlural('árboles'));
assert.equal(true, es.isPlural('cojones'));
assert.equal(true, es.isPlural('androides'));
},

'test .isSingular()': function(assert){
'test .isSingular()': function(){
assert.equal(true, es.isSingular('perro'));
assert.equal(true, es.isSingular('árbol'));
assert.equal(true, es.isSingular('cojón'));
Expand Down
14 changes: 5 additions & 9 deletions test/lingo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@ var lingo = require('lingo')
, assert = require('assert');

module.exports = {
'test .version': function(assert){
assert.match(lingo.version, /^\d+\.\d+\.\d+$/);
},

'test .capitalize()': function(assert){
'test .capitalize()': function(){
assert.equal('Hello there', lingo.capitalize('hello there'));
assert.equal('Hello There', lingo.capitalize('hello there', true));
},

'test .camelcase()': function(assert){
'test .camelcase()': function(){
assert.equal('foo', lingo.camelcase('foo'));
assert.equal('fooBar', lingo.camelcase('foo bar'));
assert.equal('fooBarBaz', lingo.camelcase('foo bar baz'));
assert.equal('base64Encode', lingo.camelcase('base -! 64 encode'));
assert.equal('UserRole', lingo.camelcase('user role', true));
},

'test .underscore()': function(assert){
'test .underscore()': function(){
assert.equal('user', lingo.underscore('User'));
assert.equal('user_account', lingo.underscore('UserAccount'))
},

'test .join()': function(assert){
'test .join()': function(){
assert.equal('foo', lingo.join(['foo']));
assert.equal('foo and bar', lingo.join(['foo', 'bar']));
assert.equal('foo, bar and baz', lingo.join(['foo', 'bar', 'baz']));
assert.equal('foo, bar or baz', lingo.join(['foo', 'bar', 'baz'], 'or'));
},

'test Language mapping': function(assert){
'test Language mapping': function(){
assert.equal('en', lingo.en.code);
}
}
4 changes: 2 additions & 2 deletions test/translation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ fr.translations = {
};

module.exports = {
'test .translate()': function(assert){
'test .translate()': function(){
assert.equal('Hello World', en.translate('Hello World'));
assert.equal('Hello TJ', en.translate('Hello {name}', { name: 'TJ' }));
assert.equal('Hello foo bar', en.translate('Hello {first} {last}', { first: 'foo', last: 'bar' }));
},

'test .translate() with translations': function(assert){
'test .translate() with translations': function(){
assert.equal('Bonjour tout le monde', fr.translate('Hello World'));
assert.equal('Bonjour TJ', fr.translate('Hello {name}', { name: 'TJ' }));
assert.equal('Bonjour foo bar', fr.translate('Hello {first} {last}', { first: 'foo', last: 'bar' }));
Expand Down

0 comments on commit ef4f933

Please sign in to comment.