mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-03 08:15:38 +00:00
chore: update vitest to 5, jsdom to 30 and typescript to 6
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { formatBadgeCount, renderBadgedFavicon } from '@/lib/favicon-badge';
|
||||
|
||||
const BASE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="1000pt" height="1000pt"><defs><clipPath id="_clip1"><rect width="1000" height="1000"/></clipPath></defs><g clip-path="url(#_clip1)"><rect width="1000" height="1000" fill="#123456"/></g></svg>`;
|
||||
@@ -165,9 +165,20 @@ describe('renderBadgedFavicon', () => {
|
||||
});
|
||||
|
||||
it('returns null rather than throwing when the source contains a lone surrogate', () => {
|
||||
const bad = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><title>abc\uD800def</title></svg>`;
|
||||
expect(() => renderBadgedFavicon(bad, 3)).not.toThrow();
|
||||
expect(renderBadgedFavicon(bad, 3)).toBeNull();
|
||||
// Browsers keep the lone surrogate through parsing and serialising, so
|
||||
// encodeURIComponent throws on it. jsdom swaps it for U+FFFD while
|
||||
// parsing, so hand the serialiser's output the surrogate directly.
|
||||
const serialize = XMLSerializer.prototype.serializeToString;
|
||||
vi.spyOn(XMLSerializer.prototype, 'serializeToString').mockImplementation(function (this: XMLSerializer, node: Node) {
|
||||
return serialize.call(this, node).replace('abc', 'abc\uD800');
|
||||
});
|
||||
const bad = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><title>abcdef</title></svg>`;
|
||||
try {
|
||||
expect(() => renderBadgedFavicon(bad, 3)).not.toThrow();
|
||||
expect(renderBadgedFavicon(bad, 3)).toBeNull();
|
||||
} finally {
|
||||
vi.restoreAllMocks();
|
||||
}
|
||||
});
|
||||
|
||||
it('sizes the badge to the label, and only "99+" fills the full icon width', () => {
|
||||
|
||||
Generated
+282
-360
File diff suppressed because it is too large
Load Diff
+5
-6
@@ -93,7 +93,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
||||
"@typescript-eslint/parser": "^8.72.1",
|
||||
"@vitejs/plugin-react": "^6.1.2",
|
||||
"@vitest/ui": "^4.1.12",
|
||||
"@vitest/ui": "^5.0.5",
|
||||
"esbuild": "^0.28.2",
|
||||
"eslint": "^9.39.5",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
@@ -101,15 +101,14 @@
|
||||
"fake-indexeddb": "^6.2.6",
|
||||
"globals": "^17.13.0",
|
||||
"husky": "^9.1.7",
|
||||
"jsdom": "^28.1.0",
|
||||
"jsdom": "^30.1.3",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.1.12"
|
||||
"typescript": "^6.0.3",
|
||||
"vitest": "^5.0.5"
|
||||
},
|
||||
"overrides": {
|
||||
"flatted": "^3.4.2",
|
||||
"picomatch": "^4.0.4",
|
||||
"undici": "$undici"
|
||||
"picomatch": "^4.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { cleanup } from '@testing-library/react';
|
||||
import { afterEach, beforeEach, vi } from 'vitest';
|
||||
import { setNoThirdPartyTraffic } from '@/lib/third-party-mode';
|
||||
|
||||
Reference in New Issue
Block a user