-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.test.js
More file actions
43 lines (39 loc) · 1.29 KB
/
config.test.js
File metadata and controls
43 lines (39 loc) · 1.29 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
jest.mock(
"next/config",
() => ({
default: function getConfig() {
return {
serverRuntimeConfig: { secret: 12345 },
publicRuntimeConfig: { api: "/graphql" }
};
}
}),
{ virtual: true }
);
const config = require("./config");
describe("config", () => {
it("is populated with the runtime config", () => {
expect(config).toEqual({
serverRuntimeConfig: { secret: 12345 },
publicRuntimeConfig: { api: "/graphql" },
get: expect.any(Function),
has: expect.any(Function)
});
});
it("supports get()", () => {
expect(config.get("serverRuntimeConfig.secret")).toBe(12345);
expect(() => config.get("serverRuntimeConfig.other")).toThrow(
'Configuration property "serverRuntimeConfig.other" is not defined'
);
expect(config.get("publicRuntimeConfig.api")).toBe("/graphql");
expect(() => config.get("publicRuntimeConfig.other")).toThrow(
'Configuration property "publicRuntimeConfig.other" is not defined'
);
});
it("supports has()", () => {
expect(config.has("serverRuntimeConfig.secret")).toBe(true);
expect(config.has("serverRuntimeConfig.other")).toBe(false);
expect(config.has("publicRuntimeConfig.api")).toBe(true);
expect(config.has("publicRuntimeConfig.other")).toBe(false);
});
});