Skip to content

Commit

Permalink
test: more configuration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sahachide committed Sep 21, 2020
1 parent 183f427 commit 7ec4ff0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Config', () => {
})

it('loads configuration files correctly', async () => {
await loadConfig({}, testConfigDir, true)
await loadConfig(undefined, testConfigDir, true)

expect(config.web?.port).toBe(8080)
expect(config.web?.publicPath).toBe('/assets/')
Expand All @@ -33,4 +33,27 @@ describe('Config', () => {
expect(config.web?.publicPath).toBe('/assets/')
expect(config.database?.enable).toBe(true)
})

it("doesn't load configs twice", async () => {
await loadConfig(
{
web: {
port: 1234,
},
},
testConfigDir,
false,
)

expect(config.web?.port).toBe(3333)
})

it("loads development config when NODE_ENV isn't present", async () => {
delete process.env.NODE_ENV

await loadConfig(undefined, testConfigDir, true)
expect(config.web?.port).toBe(5555)

process.env.NODE_ENV = 'test'
})
})
5 changes: 5 additions & 0 deletions test/fixtures/config/zen.development.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
web: {
port: 5555,
},
}

0 comments on commit 7ec4ff0

Please sign in to comment.