-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathconfig.ts
More file actions
74 lines (65 loc) · 2.05 KB
/
Copy pathconfig.ts
File metadata and controls
74 lines (65 loc) · 2.05 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
67
68
69
70
71
72
73
74
import { Config } from "../src/config"
import { ConfigOptions } from "../src/config-options"
test("load config", async () => {
const config = await Config.load("__tests__/ignore.devmoji.config.js")
expect(config.pack.get("feat")?.emoji).toBe("poop")
expect(config.pack.get("fuckup")?.emoji).toBe("poop")
})
test("load typescript from config file", async () => {
const config = await Config.load("__tests__/ignore.devmoji.config.ts")
expect(config.pack.get("feat")?.emoji).toBe("poop")
expect(config.pack.get("fuckup")?.emoji).toBe("poop")
})
test("missing prop code", () => {
expect(() => {
const config = { devmoji: [{ foo: 1 }] } as unknown as ConfigOptions
new Config(config)
}).toThrow(/code is missing/)
})
test("missing prop emoji", () => {
expect(() => {
const config = {
devmoji: [{ code: "foo" }],
} as unknown as ConfigOptions
new Config(config)
}).toThrow(/Missing.*emoji.*/)
})
test("config without devmoji", () => {
const config = { types: [] } as unknown as ConfigOptions
expect(() => {
new Config(config)
}).not.toThrow()
})
test("invalid gitmoji", () => {
const config = {
devmoji: [{ code: "test", gitmoji: "foobar" }],
} as unknown as ConfigOptions
expect(() => {
new Config(config)
}).toThrow(/Gitmoji .* not found/)
})
test("default config file", async () => {
try {
await Config.load()
} catch (error) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
expect(error).toMatch(/missing.*/)
}
})
test("no default config file", async () => {
try {
await Config.load(undefined, "/")
} catch (error) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
expect(error).toMatch(/missing.*/)
}
})
test("config file does not exist", async () => {
const configFile = "__tests__/fake.devmoji.config.js"
try {
await Config.load(configFile, "/")
} catch (error) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
expect(error).toMatch(`Config file not found ${configFile}`)
}
})