|
1 | 1 | import { describe, it, expect } from "vite-plus/test"; |
2 | 2 |
|
3 | 3 | import { |
4 | | - DISTRO_NAME_PATTERN, |
5 | 4 | extractDistroFromUncPath, |
6 | 5 | isValidDistroName, |
7 | 6 | parseWslDistroList, |
8 | | - resolveWslHomeUncPath, |
9 | 7 | resolveWslPickFolderDefaultPath, |
10 | 8 | wslUncPathToLinuxPath, |
11 | 9 | } from "./wslPathParsing.ts"; |
@@ -116,29 +114,6 @@ describe("wslUncPathToLinuxPath", () => { |
116 | 114 | }); |
117 | 115 | }); |
118 | 116 |
|
119 | | -describe("resolveWslHomeUncPath", () => { |
120 | | - const distros = [ |
121 | | - { name: "Debian", isDefault: true, version: 2 as const }, |
122 | | - { name: "Ubuntu", isDefault: false, version: 2 as const }, |
123 | | - ]; |
124 | | - |
125 | | - it("uses the configured distro when one is selected", () => { |
126 | | - expect(resolveWslHomeUncPath({ distro: "Ubuntu" }, distros)).toBe( |
127 | | - "\\\\wsl.localhost\\Ubuntu\\home", |
128 | | - ); |
129 | | - }); |
130 | | - |
131 | | - it("uses the actual default distro when config uses the WSL default", () => { |
132 | | - expect(resolveWslHomeUncPath({ distro: null }, distros)).toBe( |
133 | | - "\\\\wsl.localhost\\Debian\\home", |
134 | | - ); |
135 | | - }); |
136 | | - |
137 | | - it("omits the default path when no default distro is known", () => { |
138 | | - expect(resolveWslHomeUncPath({ distro: null }, [])).toBeNull(); |
139 | | - }); |
140 | | -}); |
141 | | - |
142 | 117 | describe("resolveWslPickFolderDefaultPath", () => { |
143 | 118 | const config = { distro: null }; |
144 | 119 | const distros = [{ name: "Debian", isDefault: true, version: 2 as const }]; |
@@ -184,23 +159,22 @@ describe("resolveWslPickFolderDefaultPath", () => { |
184 | 159 | }); |
185 | 160 | }); |
186 | 161 |
|
187 | | -describe("DISTRO_NAME_PATTERN / isValidDistroName", () => { |
| 162 | +describe("isValidDistroName", () => { |
188 | 163 | it("accepts common distro names", () => { |
189 | 164 | for (const name of ["Ubuntu", "Ubuntu-22.04", "kali-linux", "Debian", "Ubuntu 22.04"]) { |
190 | | - expect(DISTRO_NAME_PATTERN.test(name)).toBe(true); |
191 | 165 | expect(isValidDistroName(name)).toBe(true); |
192 | 166 | } |
193 | 167 | }); |
194 | 168 |
|
195 | 169 | it("rejects names with trailing whitespace, hyphen, or dot", () => { |
196 | 170 | for (const name of ["Ubuntu ", "Ubuntu-", "Ubuntu."]) { |
197 | | - expect(DISTRO_NAME_PATTERN.test(name)).toBe(false); |
| 171 | + expect(isValidDistroName(name)).toBe(false); |
198 | 172 | } |
199 | 173 | }); |
200 | 174 |
|
201 | 175 | it("rejects names containing control or shell-meta characters", () => { |
202 | 176 | for (const name of ["bad\nname", "bad\tname", "bad/name", "bad!name", "bad;name"]) { |
203 | | - expect(DISTRO_NAME_PATTERN.test(name)).toBe(false); |
| 177 | + expect(isValidDistroName(name)).toBe(false); |
204 | 178 | } |
205 | 179 | }); |
206 | 180 | }); |
0 commit comments