Skip to content

Commit 5971ff6

Browse files
committed
feat: improve config tests
1 parent 3fa6802 commit 5971ff6

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/test/config.test.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { Position, Range, workspace } from "vscode";
1+
import { workspace } from "vscode";
22
import {
3-
Config,
4-
CSSVarRecord,
53
DEFAULT_CONFIG,
64
CACHE,
75
WorkspaceConfig,
86
} from "../constants";
97
import { setup } from "../main";
10-
import { Region } from "../utils";
11-
import { getLocalCSSVarLocation } from "./test-utilities";
128

139
jest.mock("../constants", () => ({
1410
...jest.requireActual("../constants"),
@@ -108,5 +104,35 @@ test("should work for string array set to other values in config", async () => {
108104
const { config } = await setup();
109105
expect(config[CACHE.activeRootPath].ignore.length).toBe(2);
110106
expect(config[CACHE.activeRootPath].ignore).toContain("foo");
111-
expect(config[CACHE.activeRootPath].ignore).not.toContain("**/node_modules/**");
107+
expect(config[CACHE.activeRootPath].ignore).not.toContain(
108+
"**/node_modules/**"
109+
);
110+
});
111+
112+
test("should convert configs mode, postcssPLugins, postcssSyntax", async () => {
113+
wcGet.mockImplementation((key: keyof WorkspaceConfig) => {
114+
switch (key) {
115+
case "mode":
116+
return "warn";
117+
case "postcssPlugins":
118+
return ["foo"]; // Old pattern
119+
case "postcssSyntax":
120+
return { "postcss-styled": ["styl", "css"] };
121+
case "themes":
122+
return null;
123+
default:
124+
return DEFAULT_CONFIG[key];
125+
}
126+
});
127+
128+
const { config } = await setup();
129+
expect(config[CACHE.activeRootPath].mode).toMatchObject(["warn", {}]);
130+
expect(config[CACHE.activeRootPath].postcssPlugins).toMatchObject([
131+
["foo", {}],
132+
]);
133+
expect(config[CACHE.activeRootPath].postcssSyntax).toMatchObject({
134+
styl: "postcss-styled",
135+
css: "postcss-styled",
136+
});
137+
expect(config[CACHE.activeRootPath].themes).toMatchObject([]);
112138
});

0 commit comments

Comments
 (0)