qipp-config-environment
Advanced tools
Comparing version 1.1.2 to 2.0.1
{ | ||
"name": "qipp-config-environment", | ||
"version": "1.1.2", | ||
"version": "2.0.1", | ||
"title": "Environment configuration", | ||
@@ -39,7 +39,6 @@ "description": "Environment configuration file for the ATH clients.", | ||
"lint": "standard --verbose | snazzy", | ||
"pretest": "npm up && npm run lint", | ||
"test": "karma start", | ||
"preversion": "npm test", | ||
"test": "npm run lint && karma start", | ||
"preversion": "npm up && npm test", | ||
"version": "git add -A", | ||
"postversion": "git push origin master && git push --tags origin master" | ||
"postversion": "git push --tags origin master && npm publish" | ||
}, | ||
@@ -50,2 +49,3 @@ "standard": { | ||
"beforeEach", | ||
"afterEach", | ||
"describe", | ||
@@ -52,0 +52,0 @@ "expect", |
@@ -14,12 +14,9 @@ ;(function () { | ||
// Get an instance of the $windowProvider. | ||
var $window = $windowProvider.$get() | ||
var parts = $window.location.href.match(/(dev-|staging-)?([\w-]+)\..+\..+/) | ||
var domain = '.qipp.com' | ||
var protocol = 'https://' | ||
config.api.host = protocol + (parts[1] || '') + 'home' + domain | ||
config.auth.host = '' | ||
config.auth.prefix = '/auth/' | ||
config.subdomain = parts[2] | ||
var match = $windowProvider.$get().location.hostname | ||
.match(/^[\w-]+\.(\w+)\.qipp\.com$/) | ||
if (match) { | ||
config.api.host = 'https://home.' + match[1] + '.qipp.com' | ||
} | ||
} | ||
]) | ||
}()) |
@@ -5,5 +5,6 @@ ;(function () { | ||
angular.module('flatapp.config', []).constant('config', { | ||
api: {}, | ||
auth: {} | ||
api: { | ||
host: 'https://home.qipp.com' | ||
} | ||
}) | ||
}()) |
@@ -7,5 +7,13 @@ ;(function () { | ||
describe('Dev-based domain', function () { | ||
afterEach(function () { | ||
inject( | ||
function (config) { | ||
config.api.host = 'https://home.qipp.com' | ||
} | ||
) | ||
}) | ||
describe('dev domain', function () { | ||
beforeEach(function () { | ||
$window = { location: { href: 'https://dev-erlenapp.qipp.com/unit' } } | ||
$window = { location: { hostname: 'erlenapp.dev.qipp.com' } } | ||
module(function ($provide) { | ||
@@ -17,8 +25,5 @@ $provide.value('$window', $window) | ||
it('Should set the api, auth and subdomain properties for a dev-based domain.', inject( | ||
it('Should set the api host for a dev domain.', inject( | ||
function (config) { | ||
expect(config.api.host).toEqual('https://dev-home.qipp.com') | ||
expect(config.auth.host).toEqual('') | ||
expect(config.auth.prefix).toEqual('/auth/') | ||
expect(config.subdomain).toEqual('erlenapp') | ||
expect(config.api.host).toEqual('https://home.dev.qipp.com') | ||
} | ||
@@ -28,5 +33,5 @@ )) | ||
describe('Dev-based domain', function () { | ||
describe('staging domain', function () { | ||
beforeEach(function () { | ||
$window = { location: { href: 'https://staging-erlenapp.qipp.com/unit' } } | ||
$window = { location: { hostname: 'erlenapp.staging.qipp.com' } } | ||
module(function ($provide) { | ||
@@ -38,12 +43,41 @@ $provide.value('$window', $window) | ||
it('Should set the api, auth and subdomain properties for a staging-based domain.', inject( | ||
it('Should set the api host for a staging domain.', inject( | ||
function (config) { | ||
expect(config.api.host).toEqual('https://staging-home.qipp.com') | ||
expect(config.auth.host).toEqual('') | ||
expect(config.auth.prefix).toEqual('/auth/') | ||
expect(config.subdomain).toEqual('erlenapp') | ||
expect(config.api.host).toEqual('https://home.staging.qipp.com') | ||
} | ||
)) | ||
}) | ||
describe('prod domain', function () { | ||
beforeEach(function () { | ||
$window = { location: { hostname: 'erlenapp.qipp.com' } } | ||
module(function ($provide) { | ||
$provide.value('$window', $window) | ||
}) | ||
module('flatapp.config') | ||
}) | ||
it('Should set the api host for a prod domain.', inject( | ||
function (config) { | ||
expect(config.api.host).toEqual('https://home.qipp.com') | ||
} | ||
)) | ||
}) | ||
describe('custom domain', function () { | ||
beforeEach(function () { | ||
$window = { location: { hostname: 'www.erlenapp.ch' } } | ||
module(function ($provide) { | ||
$provide.value('$window', $window) | ||
}) | ||
module('flatapp.config') | ||
}) | ||
it('Should set the api host for a custom domain.', inject( | ||
function (config) { | ||
expect(config.api.host).toEqual('https://home.qipp.com') | ||
} | ||
)) | ||
}) | ||
}) | ||
}()) |
137
7278
9