-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.test.js
27 lines (21 loc) · 879 Bytes
/
config.test.js
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
"use strict";
describe("config can come from env", function () {
test("works", function() {
process.env.SECRET_KEY = "abc";
process.env.PORT = "5000";
process.env.DATABASE_URL = "other";
process.env.NODE_ENV = "other";
const config = require("./config");
expect(config.SECRET_KEY).toEqual("abc");
expect(config.PORT).toEqual(5000);
expect(config.getDatabaseUri()).toEqual("postgresql://nicom:nicom@localhost/jobly");
expect(config.BCRYPT_WORK_FACTOR).toEqual(12);
delete process.env.SECRET_KEY;
delete process.env.PORT;
delete process.env.BCRYPT_WORK_FACTOR;
delete process.env.DATABASE_URL;
expect(config.getDatabaseUri()).toEqual("postgresql://nicom:nicom@localhost/jobly");
process.env.NODE_ENV = "test";
expect(config.getDatabaseUri()).toEqual("postgresql://nicom:nicom@localhost/jobly_test");
});
})