-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from rars/add-unit-tests
Add start of unit tests
- Loading branch information
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
plugins: [ | ||
'karma-jasmine', | ||
'karma-chrome-launcher' | ||
], | ||
frameworks: ['jasmine'], | ||
singleRun: false, | ||
autoWatch: true, | ||
colors: true, | ||
reporters: ['dots'], | ||
browsers: [process.env.TRAVIS ? 'Firefox' : 'Chrome'], | ||
files: [ | ||
'node_modules/angular/angular.js', | ||
'node_modules/angular-mocks/angular-mocks.js', | ||
'src/angular-environment.js', | ||
'test/*.js' | ||
], | ||
logLevel: config.LOG_ERROR | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
describe('Test environment provider', function () { | ||
|
||
var theEnvServiceProvider; | ||
var envService; | ||
|
||
beforeEach(function () { | ||
// Initialise the provider by injecting it into a fake module's | ||
// config block. | ||
var fakeModule = angular.module('test.app.environment', []); | ||
fakeModule.config(function (envServiceProvider) { | ||
theEnvServiceProvider = envServiceProvider; | ||
}); | ||
// Initialise the test.app injector. | ||
module('environment', 'test.app.environment'); | ||
inject(function () {}); | ||
envService = theEnvServiceProvider.$get(); | ||
|
||
envService.config({ | ||
vars: { | ||
development: { | ||
backend: 'https://backend-dev/' | ||
}, | ||
production: { | ||
backend: 'https://backend/' | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
describe('with envService provider', function () { | ||
it('tests the envService provider can be created', function () { | ||
expect(theEnvServiceProvider).toBeDefined(); | ||
}); | ||
|
||
it('tests the default environment for envService is development', function () { | ||
expect(envService.environment).toBe('development'); | ||
expect(envService.get()).toBe('development'); | ||
}); | ||
|
||
it('tests the environment for envService can be set', function () { | ||
envService.set('production'); | ||
expect(envService.get()).toBe('production'); | ||
}); | ||
|
||
it('tests the config var for development environment is selected', function () { | ||
expect(envService.read('backend')).toBe('https://backend-dev/'); | ||
}); | ||
|
||
it('tests the config var for production environment is selected', function () { | ||
envService.set('production'); | ||
expect(envService.read('backend')).toBe('https://backend/'); | ||
}); | ||
}); | ||
}); |