chore: remove vitest

This commit is contained in:
Slinetrac
2025-11-20 21:41:16 +08:00
parent e3da884bde
commit fcc1d4f9b5
4 changed files with 3 additions and 384 deletions

View File

@@ -30,8 +30,7 @@
"format:check": "prettier --check .",
"format:i18n": "node scripts/cleanup-unused-i18n.mjs --align --apply",
"i18n:types": "node scripts/generate-i18n-keys.mjs",
"typecheck": "tsc --noEmit",
"test": "vitest run"
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
@@ -118,8 +117,7 @@
"typescript-eslint": "^8.47.0",
"vite": "^7.2.4",
"vite-plugin-monaco-editor-esm": "^2.0.2",
"vite-plugin-svgr": "^4.5.0",
"vitest": "^4.0.12"
"vite-plugin-svgr": "^4.5.0"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [

234
pnpm-lock.yaml generated
View File

@@ -258,9 +258,6 @@ importers:
vite-plugin-svgr:
specifier: ^4.5.0
version: 4.5.0(rollup@4.46.2)(typescript@5.9.3)(vite@7.2.4(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1))
vitest:
specifier: ^4.0.12
version: 4.0.12(@types/debug@4.1.12)(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1)
packages:
@@ -1515,9 +1512,6 @@ packages:
'@rtsao/scc@1.1.0':
resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}
'@standard-schema/spec@1.0.0':
resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
'@svgr/babel-plugin-add-jsx-attribute@8.0.0':
resolution: {integrity: sha512-b9MIk7yhdS1pMCZM8VeNfUlSKVRhsHZNMl5O9SfaX0l0t5wjdgu4IDzGB8bpnGBBOjGST3rRFVsaaEtI4W6f7g==}
engines: {node: '>=14'}
@@ -1779,15 +1773,9 @@ packages:
'@tybys/wasm-util@0.10.1':
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
'@types/chai@5.2.2':
resolution: {integrity: sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==}
'@types/debug@4.1.12':
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
'@types/deep-eql@4.0.2':
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
'@types/estree-jsx@1.0.5':
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
@@ -2019,35 +2007,6 @@ packages:
peerDependencies:
vite: ^4 || ^5 || ^6 || ^7
'@vitest/expect@4.0.12':
resolution: {integrity: sha512-is+g0w8V3/ZhRNrRizrJNr8PFQKwYmctWlU4qg8zy5r9aIV5w8IxXLlfbbxJCwSpsVl2PXPTm2/zruqTqz3QSg==}
'@vitest/mocker@4.0.12':
resolution: {integrity: sha512-GsmA/tD5Ht3RUFoz41mZsMU1AXch3lhmgbTnoSPTdH231g7S3ytNN1aU0bZDSyxWs8WA7KDyMPD5L4q6V6vj9w==}
peerDependencies:
msw: ^2.4.9
vite: ^6.0.0 || ^7.0.0-0
peerDependenciesMeta:
msw:
optional: true
vite:
optional: true
'@vitest/pretty-format@4.0.12':
resolution: {integrity: sha512-R7nMAcnienG17MvRN8TPMJiCG8rrZJblV9mhT7oMFdBXvS0x+QD6S1G4DxFusR2E0QIS73f7DqSR1n87rrmE+g==}
'@vitest/runner@4.0.12':
resolution: {integrity: sha512-hDlCIJWuwlcLumfukPsNfPDOJokTv79hnOlf11V+n7E14rHNPz0Sp/BO6h8sh9qw4/UjZiKyYpVxK2ZNi+3ceQ==}
'@vitest/snapshot@4.0.12':
resolution: {integrity: sha512-2jz9zAuBDUSbnfyixnyOd1S2YDBrZO23rt1bicAb6MA/ya5rHdKFRikPIDpBj/Dwvh6cbImDmudegnDAkHvmRQ==}
'@vitest/spy@4.0.12':
resolution: {integrity: sha512-GZjI9PPhiOYNX8Nsyqdw7JQB+u0BptL5fSnXiottAUBHlcMzgADV58A7SLTXXQwcN1yZ6gfd1DH+2bqjuUlCzw==}
'@vitest/utils@4.0.12':
resolution: {integrity: sha512-DVS/TLkLdvGvj1avRy0LSmKfrcI9MNFvNGN6ECjTUHWJdlcgPDOXhjMis5Dh7rBH62nAmSXnkPbE+DZ5YD75Rw==}
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
@@ -2214,10 +2173,6 @@ packages:
ccount@2.0.1:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
chai@6.2.1:
resolution: {integrity: sha512-p4Z49OGG5W/WBCPSS/dH3jQ73kD6tiMmUM+bckNK6Jr5JHMG3k9bg/BvKR8lKmtVBKmOiuVaV2ws8s9oSbwysg==}
engines: {node: '>=18'}
chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
@@ -2455,9 +2410,6 @@ packages:
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
engines: {node: '>= 0.4'}
es-module-lexer@1.7.0:
resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==}
es-object-atoms@1.1.1:
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
engines: {node: '>= 0.4'}
@@ -2693,9 +2645,6 @@ packages:
estree-walker@2.0.2:
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
estree-walker@3.0.3:
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
esutils@2.0.3:
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
@@ -2706,10 +2655,6 @@ packages:
eventemitter3@5.0.1:
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
expect-type@1.2.2:
resolution: {integrity: sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==}
engines: {node: '>=12.0.0'}
ext@1.7.0:
resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==}
@@ -3520,9 +3465,6 @@ packages:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
pathe@2.0.3:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -3797,9 +3739,6 @@ packages:
resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
engines: {node: '>= 0.4'}
siginfo@2.0.0:
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
signal-exit@4.1.0:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
@@ -3833,15 +3772,9 @@ packages:
resolution: {integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==}
engines: {node: '>=12.0.0'}
stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
state-local@1.0.7:
resolution: {integrity: sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==}
std-env@3.10.0:
resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==}
stop-iteration-iterator@1.1.0:
resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}
engines: {node: '>= 0.4'}
@@ -3937,20 +3870,10 @@ packages:
resolution: {integrity: sha512-wFH7+SEAcKfJpfLPkrgMPvvwnEtj8W4IurvEyrKsDleXnKLCDw71w8jltvfLa8Rm4qQxxT4jmDBYbJG/z7qoww==}
engines: {node: '>=0.12'}
tinybench@2.9.0:
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
tinyexec@0.3.2:
resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
tinyglobby@0.2.15:
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
engines: {node: '>=12.0.0'}
tinyrainbow@3.0.3:
resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==}
engines: {node: '>=14.0.0'}
to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -4144,43 +4067,6 @@ packages:
yaml:
optional: true
vitest@4.0.12:
resolution: {integrity: sha512-pmW4GCKQ8t5Ko1jYjC3SqOr7TUKN7uHOHB/XGsAIb69eYu6d1ionGSsb5H9chmPf+WeXt0VE7jTXsB1IvWoNbw==}
engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@opentelemetry/api': ^1.9.0
'@types/debug': ^4.1.12
'@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0
'@vitest/browser-playwright': 4.0.12
'@vitest/browser-preview': 4.0.12
'@vitest/browser-webdriverio': 4.0.12
'@vitest/ui': 4.0.12
happy-dom: '*'
jsdom: '*'
peerDependenciesMeta:
'@edge-runtime/vm':
optional: true
'@opentelemetry/api':
optional: true
'@types/debug':
optional: true
'@types/node':
optional: true
'@vitest/browser-playwright':
optional: true
'@vitest/browser-preview':
optional: true
'@vitest/browser-webdriverio':
optional: true
'@vitest/ui':
optional: true
happy-dom:
optional: true
jsdom:
optional: true
void-elements@3.1.0:
resolution: {integrity: sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==}
engines: {node: '>=0.10.0'}
@@ -4226,11 +4112,6 @@ packages:
engines: {node: '>= 8'}
hasBin: true
why-is-node-running@2.3.0:
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
engines: {node: '>=8'}
hasBin: true
word-wrap@1.2.5:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
@@ -5645,8 +5526,6 @@ snapshots:
'@rtsao/scc@1.1.0':
optional: true
'@standard-schema/spec@1.0.0': {}
'@svgr/babel-plugin-add-jsx-attribute@8.0.0(@babel/core@7.28.4)':
dependencies:
'@babel/core': 7.28.4
@@ -5867,16 +5746,10 @@ snapshots:
tslib: 2.8.1
optional: true
'@types/chai@5.2.2':
dependencies:
'@types/deep-eql': 4.0.2
'@types/debug@4.1.12':
dependencies:
'@types/ms': 2.1.0
'@types/deep-eql@4.0.2': {}
'@types/estree-jsx@1.0.5':
dependencies:
'@types/estree': 1.0.8
@@ -6113,45 +5986,6 @@ snapshots:
transitivePeerDependencies:
- '@swc/helpers'
'@vitest/expect@4.0.12':
dependencies:
'@standard-schema/spec': 1.0.0
'@types/chai': 5.2.2
'@vitest/spy': 4.0.12
'@vitest/utils': 4.0.12
chai: 6.2.1
tinyrainbow: 3.0.3
'@vitest/mocker@4.0.12(vite@7.2.4(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1))':
dependencies:
'@vitest/spy': 4.0.12
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
vite: 7.2.4(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1)
'@vitest/pretty-format@4.0.12':
dependencies:
tinyrainbow: 3.0.3
'@vitest/runner@4.0.12':
dependencies:
'@vitest/utils': 4.0.12
pathe: 2.0.3
'@vitest/snapshot@4.0.12':
dependencies:
'@vitest/pretty-format': 4.0.12
magic-string: 0.30.21
pathe: 2.0.3
'@vitest/spy@4.0.12': {}
'@vitest/utils@4.0.12':
dependencies:
'@vitest/pretty-format': 4.0.12
tinyrainbow: 3.0.3
acorn-jsx@5.3.2(acorn@8.15.0):
dependencies:
acorn: 8.15.0
@@ -6364,8 +6198,6 @@ snapshots:
ccount@2.0.1: {}
chai@6.2.1: {}
chalk@4.1.2:
dependencies:
ansi-styles: 4.3.0
@@ -6641,8 +6473,6 @@ snapshots:
es-errors@1.3.0: {}
es-module-lexer@1.7.0: {}
es-object-atoms@1.1.1:
dependencies:
es-errors: 1.3.0
@@ -7018,10 +6848,6 @@ snapshots:
estree-walker@2.0.2: {}
estree-walker@3.0.3:
dependencies:
'@types/estree': 1.0.8
esutils@2.0.3: {}
event-emitter@0.3.5:
@@ -7031,8 +6857,6 @@ snapshots:
eventemitter3@5.0.1: {}
expect-type@1.2.2: {}
ext@1.7.0:
dependencies:
type: 2.7.3
@@ -8028,8 +7852,6 @@ snapshots:
path-type@4.0.0: {}
pathe@2.0.3: {}
picocolors@1.1.1: {}
picomatch@2.3.1: {}
@@ -8362,8 +8184,6 @@ snapshots:
side-channel-weakmap: 1.0.2
optional: true
siginfo@2.0.0: {}
signal-exit@4.1.0: {}
slice-ansi@7.1.2:
@@ -8391,12 +8211,8 @@ snapshots:
stable-hash-x@0.2.0: {}
stackback@0.0.2: {}
state-local@1.0.7: {}
std-env@3.10.0: {}
stop-iteration-iterator@1.1.0:
dependencies:
es-errors: 1.3.0
@@ -8512,17 +8328,11 @@ snapshots:
es5-ext: 0.10.64
next-tick: 1.1.0
tinybench@2.9.0: {}
tinyexec@0.3.2: {}
tinyglobby@0.2.15:
dependencies:
fdir: 6.5.0(picomatch@4.0.3)
picomatch: 4.0.3
tinyrainbow@3.0.3: {}
to-regex-range@5.0.1:
dependencies:
is-number: 7.0.0
@@ -8751,45 +8561,6 @@ snapshots:
terser: 5.44.1
yaml: 2.8.1
vitest@4.0.12(@types/debug@4.1.12)(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1):
dependencies:
'@vitest/expect': 4.0.12
'@vitest/mocker': 4.0.12(vite@7.2.4(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1))
'@vitest/pretty-format': 4.0.12
'@vitest/runner': 4.0.12
'@vitest/snapshot': 4.0.12
'@vitest/spy': 4.0.12
'@vitest/utils': 4.0.12
debug: 4.4.3
es-module-lexer: 1.7.0
expect-type: 1.2.2
magic-string: 0.30.21
pathe: 2.0.3
picomatch: 4.0.3
std-env: 3.10.0
tinybench: 2.9.0
tinyexec: 0.3.2
tinyglobby: 0.2.15
tinyrainbow: 3.0.3
vite: 7.2.4(@types/node@24.10.1)(jiti@2.6.1)(sass@1.94.2)(terser@5.44.1)(yaml@2.8.1)
why-is-node-running: 2.3.0
optionalDependencies:
'@types/debug': 4.1.12
'@types/node': 24.10.1
transitivePeerDependencies:
- jiti
- less
- lightningcss
- msw
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- tsx
- yaml
void-elements@3.1.0: {}
vscode-jsonrpc@8.2.0: {}
@@ -8856,11 +8627,6 @@ snapshots:
dependencies:
isexe: 2.0.0
why-is-node-running@2.3.0:
dependencies:
siginfo: 2.0.0
stackback: 0.0.2
word-wrap@1.2.5: {}
wrap-ansi@9.0.2:

View File

@@ -1,140 +0,0 @@
import type { Update } from "@tauri-apps/plugin-updater";
import { describe, expect, it } from "vitest";
import {
compareVersions,
ensureSemver,
extractSemver,
normalizeVersion,
resolveRemoteVersion,
splitVersion,
} from "@/services/update";
import type { VersionParts } from "@/services/update";
const makeUpdate = (data: {
version?: string | null;
rawJson?: Record<string, unknown> | null;
}): Update =>
({
version: data.version ?? "",
rawJson: data.rawJson ?? {},
}) as unknown as Update;
describe("normalizeVersion", () => {
it("strips optional v prefix and trims whitespace", () => {
expect(normalizeVersion(" v1.2.3 ")).toBe("1.2.3");
expect(normalizeVersion("V2.0.0-beta")).toBe("2.0.0-beta");
});
it("returns null for empty or non-string input", () => {
expect(normalizeVersion(null)).toBeNull();
expect(normalizeVersion(" ")).toBeNull();
});
});
describe("ensureSemver", () => {
it("returns normalized semver when input is valid", () => {
expect(ensureSemver("1.2.3")).toBe("1.2.3");
expect(ensureSemver("v3.4.5-alpha.1+build.7")).toBe(
"3.4.5-alpha.1+build.7",
);
});
it("returns null for invalid versions", () => {
expect(ensureSemver("1")).toBeNull();
expect(ensureSemver("1.2.3.4")).toBeNull();
expect(ensureSemver("release-candidate")).toBeNull();
});
});
describe("extractSemver", () => {
it("finds the first semver-like string and normalizes it", () => {
expect(extractSemver("Release v1.2.3 (latest)")).toBe("1.2.3");
expect(extractSemver("tag:V2.0.0-beta+exp.sha")).toBe("2.0.0-beta+exp.sha");
});
it("returns null when no semver-like string is present", () => {
expect(extractSemver("no version available")).toBeNull();
});
});
describe("splitVersion", () => {
it("splits version into numeric main and typed prerelease parts", () => {
const parts = splitVersion("1.2.3-alpha.4.beta") as VersionParts;
expect(parts.main).toEqual([1, 2, 3]);
expect(parts.pre).toEqual(["alpha", 4, "beta"]);
});
it("returns null when version is missing", () => {
expect(splitVersion(null)).toBeNull();
});
});
describe("compareVersions", () => {
it("orders versions by numeric components", () => {
expect(compareVersions("1.2.3", "1.2.4")).toBe(-1);
expect(compareVersions("2.0.0", "1.9.9")).toBe(1);
});
it("treats release versions as newer than prereleases", () => {
expect(compareVersions("1.0.0", "1.0.0-beta")).toBe(1);
expect(compareVersions("1.0.0-beta", "1.0.0")).toBe(-1);
});
it("resolves prerelease precedence correctly", () => {
expect(compareVersions("1.0.0-beta", "1.0.0-alpha")).toBe(1);
expect(compareVersions("1.0.0-alpha.1", "1.0.0-alpha.beta")).toBe(-1);
});
it("returns null when comparison cannot be made", () => {
expect(compareVersions(null, "1.0.0")).toBeNull();
});
});
describe("resolveRemoteVersion", () => {
it("prefers direct semver value on the update object", () => {
const update = makeUpdate({ version: "v1.2.3" });
expect(resolveRemoteVersion(update)).toBe("1.2.3");
});
it("falls back through rawJson fields when primary version is missing", () => {
const update = makeUpdate({
version: "See release notes",
rawJson: {
version: "v2.3.4",
tag_name: "ignore-me",
name: "v0.0.1",
},
});
expect(resolveRemoteVersion(update)).toBe("2.3.4");
});
it("rescues version from tag_name or name when needed", () => {
const update = makeUpdate({
version: "no version here",
rawJson: {
tag_name: "release-v3.1.0",
name: "build-should-not-override",
},
});
expect(resolveRemoteVersion(update)).toBe("3.1.0");
const nameOnly = makeUpdate({
version: "invalid",
rawJson: {
name: "release v4.0.0-beta.1",
},
});
expect(resolveRemoteVersion(nameOnly)).toBe("4.0.0-beta.1");
});
it("returns null when no semver-like data is present", () => {
const update = makeUpdate({
version: "not-a-version",
rawJson: {
name: "nope",
},
});
expect(resolveRemoteVersion(update)).toBeNull();
});
});

View File

@@ -2,9 +2,9 @@ import path from "node:path";
import legacy from "@vitejs/plugin-legacy";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import monacoEditorPlugin from "vite-plugin-monaco-editor-esm";
import svgr from "vite-plugin-svgr";
import { defineConfig } from "vitest/config";
const getPackageName = (id: string) => {
// Walk through possible pnpm virtual paths and nested node_modules, return the last package segment.
@@ -183,11 +183,6 @@ export default defineConfig({
"@root": path.resolve("."),
},
},
test: {
environment: "node",
include: ["**/*.{test,spec}.{ts,tsx}"],
},
define: {
OS_PLATFORM: `"${process.platform}"`,
},