master
1import Configuration from '../configuration';
2
3describe("Configuration", ()=> {
4 let subject = null;
5
6 describe("without overrides", () => {
7 beforeEach(() => {
8 subject = new Configuration();
9 });
10
11 it ("loads the api host", () => {
12 expect(subject.value_for("API_HOST")).toEqual('https://www.stronglifters.com')
13 });
14
15 it ("loads the default ENV", () => {
16 expect(subject.value_for("ENV")).toEqual('production')
17 });
18 });
19
20 describe("with overrides", () => {
21 let overrides = null;
22
23 beforeEach(() => {
24 overrides = { ENV: 'development', API_HOST: 'http://localhost:3000' };
25 subject = new Configuration(overrides);
26 });
27
28 it ("loads the override for API_HOST", () => {
29 expect(subject.value_for("API_HOST")).toEqual('http://localhost:3000')
30 });
31
32 it ("loads the override for ENV", () => {
33 expect(subject.value_for("ENV")).toEqual('development')
34 });
35
36 it ("merges defaults with the overrides", () => {
37 overrides = { API_HOST: 'http://localhost:3000' };
38 subject = new Configuration(overrides);
39
40 expect(subject.value_for("ENV")).toEqual('production')
41 expect(subject.value_for("API_HOST")).toEqual('http://localhost:3000')
42 });
43 });
44});