diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d62fe2c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "6" +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - npm install diff --git a/karma.conf.js b/karma.conf.js index dde99ca..7e4432a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,7 +2,8 @@ module.exports = function (config) { config.set({ plugins: [ 'karma-jasmine', - 'karma-chrome-launcher' + 'karma-chrome-launcher', + 'karma-firefox-launcher' ], frameworks: ['jasmine'], singleRun: false, diff --git a/test/angular-environment.js b/test/angular-environment.js index 4640af3..1ba64f0 100644 --- a/test/angular-environment.js +++ b/test/angular-environment.js @@ -30,14 +30,18 @@ describe('Test environment provider', function () { theEnvServiceProvider.config({ domains: { development: ['localhost'], - production: ['app.*.com'] + production: ['app.*.com', 'app.web.co.uk'] }, vars: { development: { - backend: 'https://backend-dev/' + backend: 'https://backend-dev/', + authServiceUrl: 'https://auth-server-dev/' }, production: { backend: 'https://backend/' + }, + defaults: { + authServiceUrl: 'https://auth-server/' } } }); @@ -71,6 +75,34 @@ describe('Test environment provider', function () { envService.set('production'); expect(envService.read('backend')).toBe('https://backend/'); }); + + it('tests the correct environment is identified by name using is method', function () { + expect(envService.is('development')).toBe(true); + expect(envService.is('production')).toBe(false); + envService.set('production'); + expect(envService.is('development')).toBe(false); + expect(envService.is('production')).toBe(true); + }); + + (function () { + var i = 0, args = [undefined, '', 'all']; + + for (i = 0; i < args.length; i++) { + it('tests all config is returned if read(' + args[i] + ') is called', function () { + var config = envService.read(args[i]); + expect(Object.keys(config).length).toBe(2); + expect(config.authServiceUrl).toBe('https://auth-server-dev/'); + expect(config.backend).toBe('https://backend-dev/'); + }); + } + })(); + + it('tests default value should be chosen from config if value is undefined for the environment', + function () { + expect(envService.read('authServiceUrl')).toBe('https://auth-server-dev/'); + envService.set('production'); + expect(envService.read('authServiceUrl')).toBe('https://auth-server/'); + }); }); describe('tests matching domains', function () {