forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonfig_spec.coffee
More file actions
66 lines (47 loc) · 1.66 KB
/
Copy pathkonfig_spec.coffee
File metadata and controls
66 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require("../spec_helper")
describe "lib/konfig", ->
beforeEach ->
@env = process.env["CYPRESS_ENV"]
@setup = (env) =>
process.env["CYPRESS_ENV"] = env
@konfig = require("#{root}lib/konfig")
@eq = (key, val) =>
expect(@konfig(key)).to.eq(val)
afterEach ->
process.env["CYPRESS_ENV"] = @env
delete require.cache[require.resolve("#{root}lib/konfig")]
it "does not set global.config", ->
delete global.config
delete require.cache[require.resolve("#{root}lib/konfig")]
require("#{root}lib/konfig")
expect(global.config).not.to.be.ok
it "memoizes the result", ->
env = process.env["NODE_ENV"]
process.env["NODE_ENV"] = "development"
config = require("#{root}lib/konfig")
process.env["NODE_ENV"] = "test"
config2 = require("#{root}lib/konfig")
expect(config).to.eq(config2)
it "does not add NODE_ENV to process env if input env did not contain one", ->
env = process.env["NODE_ENV"]
delete process.env["NODE_ENV"]
delete require.cache[require.resolve("#{root}lib/konfig")]
expect(process.env.hasOwnProperty('NODE_ENV')).to.eq(false)
config = require("#{root}lib/konfig")
expect(process.env.hasOwnProperty('NODE_ENV')).to.eq(false)
process.env["NODE_ENV"] = env
context "development", ->
beforeEach ->
@setup("development")
it "api_url", ->
@eq("api_url", "http://localhost:1234/")
context "test", ->
beforeEach ->
@setup("test")
it "api_url", ->
@eq("api_url", "http://localhost:1234/")
context "production", ->
beforeEach ->
@setup("production")
it "api_url", ->
@eq("api_url", "https://api.cypress.io/")