Commit 2572430
Changed files (3)
app
infrastructure
app/infrastructure/__tests__/configuration_spec.js
@@ -3,13 +3,27 @@ import Configuration from '../configuration';
describe("Configuration", ()=> {
let subject = null;
- beforeEach(()=> {
- subject = new Configuration('development');
+ describe("development", () => {
+ beforeEach(()=> {
+ subject = new Configuration('development');
+ });
+
+ it ("loads the api host", function() {
+ expect(
+ subject.value_for("API_HOST")
+ ).toEqual('http://localhost:3000')
+ });
});
- it ("loads the specified configuration", function() {
- let apiHost='http://192.168.128.6:3000'
+ describe("production", () => {
+ beforeEach(()=> {
+ subject = new Configuration('production');
+ });
- expect(subject.value_for("API_HOST")).toEqual(apiHost)
+ it ("loads the api host", function() {
+ expect(
+ subject.value_for("API_HOST")
+ ).toEqual('https://www.stronglifters.com')
+ });
});
});
app/infrastructure/api.js
@@ -46,8 +46,7 @@ export default class Api {
}
buildUrlFor(url) {
- //let host = this.configuration.value_for('API_HOST');
- let host = 'https://localhost:3000';
+ let host = this.configuration.value_for('API_HOST');
return `${host}/api${url}`
}
}
app/infrastructure/configuration.js
@@ -1,11 +1,21 @@
import Config from 'react-native-config';
+var _configuration = {
+ development: {
+ API_HOST: 'http://localhost:3000'
+ },
+ production: {
+ API_HOST: 'https://www.stronglifters.com'
+ }
+};
+
export default class Configuration {
constructor(environment) {
this.environment = environment;
}
value_for(key) {
- return Config[key];
+ //return Config[key];
+ return _configuration[this.environment][key];
}
}