Permalink
Browse files

reformated tests

  • Loading branch information...
1 parent 56242e7 commit 213a10844e5140df2988fbe4c0b9448019c705e8 @mashpie committed May 26, 2012
Showing with 96 additions and 96 deletions.
  1. +21 −22 test/i18n.configure.js
  2. +75 −74 test/i18n.test.js
@@ -1,28 +1,27 @@
// Run $ expresso
-
var i18n = require('../i18n'),
assert = require('assert'),
fs = require('fs');
- i18n.configure({
- locales:['en', 'de'],
- register: global,
- directory: './testlocales',
- debug: true
- });
+i18n.configure({
+ locales: ['en', 'de'],
+ register: global,
+ directory: './testlocales',
+ debug: true
+});
+
+module.exports = {
+ 'check set/getLocale': function () {
+ var loc = i18n.getLocale();
+ assert.equal('en', i18n.getLocale(), 'should return default setting');
+ assert.equal('de', i18n.setLocale('de'), 'should return the new setting');
+ assert.equal('de', i18n.getLocale(), 'should return the new setting');
+ },
-module.exports = {
- 'check set/getLocale': function(){
- var loc = i18n.getLocale();
- assert.equal('en', i18n.getLocale(), 'should return default setting');
- assert.equal('de', i18n.setLocale('de'), 'should return the new setting');
- assert.equal('de', i18n.getLocale(), 'should return the new setting');
- },
-
- 'check singular': function(){
- i18n.setLocale('en');
- assert.equal(__('Hello'), 'Hello');
- assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hello Marcus, how are you today?');
- assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hello Marcus, how are you today? How was your weekend.');
- }
-};
+ 'check singular': function () {
+ i18n.setLocale('en');
+ assert.equal(__('Hello'), 'Hello');
+ assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hello Marcus, how are you today?');
+ assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hello Marcus, how are you today? How was your weekend.');
+ }
+};
View
@@ -1,80 +1,81 @@
// Run $ expresso
-
var i18n = require('../i18n'),
assert = require('assert');
- i18n.configure({
- // setup some locales - other locales default to en silently
- locales:['en', 'de'],
-
- // where to register __() and __n() to, might be "global" if you know what you are doing
- register: global
- });
+i18n.configure({
+ // setup some locales - other locales default to en silently
+ locales: ['en', 'de'],
+
+ // where to register __() and __n() to, might be "global" if you know what you are doing
+ register: global
+
+});
module.exports = {
- 'check version': function() {
- assert.equal(i18n.version, '0.3.4');
- },
-
- 'check set/getLocale': function(){
- assert.equal('en', i18n.getLocale(), 'should return default setting');
- assert.equal('de', i18n.setLocale('de'), 'should return the new setting');
- assert.equal('de', i18n.getLocale(), 'should return the new setting');
- },
-
- 'check singular': function() {
- i18n.setLocale('en');
- assert.equal(__('Hello'), 'Hello');
- assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hello Marcus, how are you today?');
- assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hello Marcus, how are you today? How was your weekend.');
-
- i18n.setLocale('de');
- assert.equal(__('Hello'), 'Hallo');
- assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hallo Marcus, wie geht es dir heute?');
- assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hallo Marcus, wie geht es dir heute? Wie war dein Wochenende.');
-
- },
-
- 'check plural': function() {
- i18n.setLocale('en');
- var singular = __n('%s cat', '%s cats', 1);
- var plural = __n('%s cat', '%s cats', 3);
- assert.equal(singular, '1 cat');
- assert.equal(plural, '3 cats');
-
- i18n.setLocale('de');
- var singular = __n('%s cat', '%s cats', 1);
- var plural = __n('%s cat', '%s cats', 3);
- assert.equal(singular, '1 Katze');
- assert.equal(plural, '3 Katzen');
- },
-
- 'check nested plural': function() {
- i18n.setLocale('en');
- var singular = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 1, __('tree'));
- var plural = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 3, __('tree'));
- assert.equal(singular, 'There is one monkey in the tree');
- assert.equal(plural, 'There are 3 monkeys in the tree');
-
- i18n.setLocale('de');
- var singular = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 1, __('tree'));
- var plural = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 3, __('tree'));
- assert.equal(singular, 'Im Baum sitzt ein Affe');
- assert.equal(plural, 'Im Baum sitzen 3 Affen');
-
- },
-
- 'check variables': function() {
- i18n.setLocale('en');
- var greetings = ['Hi', 'Hello', 'Howdy'];
- for (var i=0; i < greetings.length; i++) {
- assert.equal(greetings[i], __(greetings[i]));
- };
-
- i18n.setLocale('de');
- var greetingsDE = ['Hi', 'Hallo', 'Hallöchen'];
- for (var i=0; i < greetings.length; i++) {
- assert.equal(greetingsDE[i], __(greetings[i]));
- };
- }
-};
+ 'check version': function () {
+ assert.equal(i18n.version, '0.3.4');
+ },
+
+ 'check set/getLocale': function () {
+ assert.equal('en', i18n.getLocale(), 'should return default setting');
+ assert.equal('de', i18n.setLocale('de'), 'should return the new setting');
+ assert.equal('de', i18n.getLocale(), 'should return the new setting');
+ },
+
+ 'check singular': function () {
+ i18n.setLocale('en');
+ assert.equal(__('Hello'), 'Hello');
+ assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hello Marcus, how are you today?');
+ assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hello Marcus, how are you today? How was your weekend.');
+
+ i18n.setLocale('de');
+ assert.equal(__('Hello'), 'Hallo');
+ assert.equal(__('Hello %s, how are you today?', 'Marcus'), 'Hallo Marcus, wie geht es dir heute?');
+ assert.equal(__('Hello %s, how are you today? How was your %s.', 'Marcus', __('weekend')), 'Hallo Marcus, wie geht es dir heute? Wie war dein Wochenende.');
+
+ },
+
+ 'check plural': function () {
+ i18n.setLocale('en');
+ var singular = __n('%s cat', '%s cats', 1);
+ var plural = __n('%s cat', '%s cats', 3);
+ assert.equal(singular, '1 cat');
+ assert.equal(plural, '3 cats');
+
+ i18n.setLocale('de');
+ singular = __n('%s cat', '%s cats', 1);
+ plural = __n('%s cat', '%s cats', 3);
+ assert.equal(singular, '1 Katze');
+ assert.equal(plural, '3 Katzen');
+ },
+
+ 'check nested plural': function () {
+ i18n.setLocale('en');
+ var singular = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 1, __('tree'));
+ var plural = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 3, __('tree'));
+ assert.equal(singular, 'There is one monkey in the tree');
+ assert.equal(plural, 'There are 3 monkeys in the tree');
+
+ i18n.setLocale('de');
+ singular = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 1, __('tree'));
+ plural = __n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 3, __('tree'));
+ assert.equal(singular, 'Im Baum sitzt ein Affe');
+ assert.equal(plural, 'Im Baum sitzen 3 Affen');
+
+ },
+
+ 'check variables': function () {
+ var i = 0;
+ i18n.setLocale('en');
+ var greetings = ['Hi', 'Hello', 'Howdy'];
+ for (i = 0; i < greetings.length; i++) {
+ assert.equal(greetings[i], __(greetings[i]));
+ };
+
+ i18n.setLocale('de');
+ var greetingsDE = ['Hi', 'Hallo', 'Hallöchen'];
+ for (i = 0; i < greetings.length; i++) {
+ assert.equal(greetingsDE[i], __(greetings[i]));
+ };
+ }
+};

0 comments on commit 213a108

Please sign in to comment.