generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.test.js
93 lines (77 loc) · 1.78 KB
/
index.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const { it, expect } = require("@jest/globals");
const dotenvAction = require("./dotenv_action");
it("fails when path does not exist and 'ensure-exists' is 'true'", () => {
expect(() =>
dotenvAction({
path: "nosuchfile",
ensureExists: true,
}),
).toThrow(Error);
});
it("runs when path does not exist and 'ensure-exists' is 'false'", () => {
const actual = dotenvAction({
path: "nosuchfile",
ensureExists: false,
});
expect(actual).toEqual({});
});
it("runs with custom path", () => {
const actual = dotenvAction({
path: "fixtures/.env",
});
expect(actual).toEqual({
fixtures_1: "123",
});
});
it("runs with another custom path", () => {
const actual = dotenvAction({
path: "fixtures/.another.env",
});
expect(actual).toEqual({
fixtures_2: "xyz",
other_key: "this",
});
});
it("runs with expanded values", () => {
const actual = dotenvAction({
path: "fixtures/.expand.env",
});
expect(actual).toEqual({
fixtures_3: "xyz",
expanded: "123-xyz",
expanded_2: "123-xyz",
});
});
it("runs with bypass case for keys", () => {
const actual = dotenvAction({
path: "fixtures/.case.env",
keysCase: "bypass",
});
expect(actual).toEqual({
FIXTURES_4: "foo",
fixtures_5: "bar",
Fixtures_6: "abc",
});
});
it("runs with lower case for keys", () => {
const actual = dotenvAction({
path: "fixtures/.case.env",
keysCase: "lower",
});
expect(actual).toEqual({
fixtures_4: "foo",
fixtures_5: "bar",
fixtures_6: "abc",
});
});
it("runs with upper case for keys", () => {
const actual = dotenvAction({
path: "fixtures/.case.env",
keysCase: "upper",
});
expect(actual).toEqual({
FIXTURES_4: "foo",
FIXTURES_5: "bar",
FIXTURES_6: "abc",
});
});