From 9b55ef4d061d4be8a08b614bfe808807722905b4 Mon Sep 17 00:00:00 2001 From: Anthony Verez Date: Sat, 24 May 2014 18:06:21 -0700 Subject: [PATCH] Integration tests for i18n hook --- test/integration/hook.i18n.test.js | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 test/integration/hook.i18n.test.js diff --git a/test/integration/hook.i18n.test.js b/test/integration/hook.i18n.test.js new file mode 100644 index 000000000..e3c7e0f92 --- /dev/null +++ b/test/integration/hook.i18n.test.js @@ -0,0 +1,77 @@ +var assert = require('assert'); +var httpHelper = require('./helpers/httpHelper.js'); +var appHelper = require('./helpers/appHelper'); +var path = require('path'); +var fs = require('fs'); + +describe('i18n ::', function() { + + var appName = 'testApp'; + + beforeEach(function(done) { + appHelper.lift({ + verbose: false + }, function(err, sails) { + if (err) { + throw new Error(err); + } + sailsprocess = sails; + sailsprocess.once('hook:http:listening', done); + }); + }); + + afterEach(function(done) { + sailsprocess.kill(done); + }); + + before(function(done) { + this.timeout(5000); + appHelper.build(done); + }); + + after(function() { + // console.log('before `chdir ../`' + ', cwd was :: ' + process.cwd()); + process.chdir('../'); + // console.log('after `chdir ../`' + ', cwd was :: ' + process.cwd()); + appHelper.teardown(); + }); + + describe('with locales generate by sails-generate-backend', function () { + it('should say "Welcome" by default', function(done) { + assert(sailsprocess.__('Welcome') == 'Welcome'); + done(); + }); + + it('should say "Welcome" in English', function(done) { + assert(sailsprocess.__({ + phrase: 'Welcome', + locale: 'en' + }) == 'Welcome'); + done(); + }); + + it('should say "Bienvenido" in Spanish', function(done) { + assert(sailsprocess.__({ + phrase: 'Welcome', + locale: 'es' + }) == 'Bienvenido'); + done(); + }); + + it('should say "Bienvenue" in French', function(done) { + assert(sailsprocess.__({ + phrase: 'Welcome', + locale: 'fr' + }) == 'Bienvenue'); + done(); + }); + + it('should say "Wilkommen" in German', function(done) { + assert(sailsprocess.__({ + phrase: 'Welcome', + locale: 'de' + }) == 'Wilkommen'); + done(); + }); + }); +});