|
1 | | -import { Position, Range, workspace } from "vscode"; |
| 1 | +import { workspace } from "vscode"; |
2 | 2 | import { |
3 | | - Config, |
4 | | - CSSVarRecord, |
5 | 3 | DEFAULT_CONFIG, |
6 | 4 | CACHE, |
7 | 5 | WorkspaceConfig, |
8 | 6 | } from "../constants"; |
9 | 7 | import { setup } from "../main"; |
10 | | -import { Region } from "../utils"; |
11 | | -import { getLocalCSSVarLocation } from "./test-utilities"; |
12 | 8 |
|
13 | 9 | jest.mock("../constants", () => ({ |
14 | 10 | ...jest.requireActual("../constants"), |
@@ -108,5 +104,35 @@ test("should work for string array set to other values in config", async () => { |
108 | 104 | const { config } = await setup(); |
109 | 105 | expect(config[CACHE.activeRootPath].ignore.length).toBe(2); |
110 | 106 | 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([]); |
112 | 138 | }); |
0 commit comments