Add Vitest test suite for pure-logic modules - #1927
Conversation
| @@ -0,0 +1,99 @@ | |||
| /* | |||
| * Copyright 2010-2020 Gildas Lormeau | |||
There was a problem hiding this comment.
| * Copyright 2010-2020 Gildas Lormeau | |
| * Copyright 2010-2026 Gildas Lormeau |
Test srcset parser, MHTML utilities, yabson serialization round-trips, and config/download helpers. Extract pure functions from config.js and downloads.js into config-utils.js to make them importable without browser API dependencies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove unused MIGRATION_DEFAULT_VARIABLES_VALUES import in config.js (only updateFilenameTemplate needs it, and it lives in config-utils.js) - Declare TextEncoder/atob globals in mhtml-util.test.js so the test file passes eslint - Add @eslint/js to devDependencies: eslint.config.mjs imports it, but eslint 10 no longer ships it as a transitive dependency, so "npx eslint ." fails on a fresh checkout - Add tests for decodeBinary and decodeBase64 (base64 encoding of the full byte range, chunk-boundary-sized input, charset handling) - Collapse leftover double blank lines where functions were extracted Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thank you for taking the time to write this. The tests are good, but most of them are not in the right place. Three of the four test files cover code that is vendored into this repository: srcset-parser and the MHTML utilities come from the mhtml-to-html project, and yabson has its own repository. The copies here get replaced wholesale when the upstream changes. This has already happened since this PR was opened, the functions tested by mhtml-util.test.js no longer exist in that shape. The plan is to add these tests in each sub-project, where the code is actually developed. I'll keep this PR open as a reminder and close it once that's done. If you'd like to contribute the yabson and srcset tests upstream, they are very welcome there. The |
|
Makes sense. I've ported the tests upstream:
I left the MHTML utility tests alone since your suite over there already covers them. |
Some ideas about how a test suite for SingleFile might look. Let me know your thoughts @gildas-lormeau!
Summary
decodeBinary/decodeBase64), yabson serialization round-trips, and config/download helpers@eslint/jsto devDependencies: eslint.config.mjs imports it, but ESLint 10 no longer ships it as a transitive dependency, sonpx eslint .fails on a fresh checkout without itTest plan
preserve-caught-errorhits from ESLint 10's new recommended rule, unrelated to this change)