Skip to content

Commit

Permalink
Update Vitest to v1 (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored Jan 30, 2024
1 parent 95db585 commit c5f4a71
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 444 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('applies `dir="auto"` to inline code', async () => {
expect(output).not.toEqual(input);
expect(output).includes('dir="auto"');
expect(output).toMatchInlineSnapshot(
'"<p>Some text with <code dir=\\"auto\\">inline code</code>.</p>"'
`"<p>Some text with <code dir="auto">inline code</code>.</p>"`
);
});

Expand All @@ -20,6 +20,6 @@ test('applies `dir="ltr"` to code blocks', async () => {
expect(output).not.toEqual(input);
expect(output).includes('dir="ltr"');
expect(output).toMatchInlineSnapshot(
'"<p>Some text in a paragraph:</p><pre dir=\\"ltr\\"><code>console.log(\'test\')</code></pre>"'
`"<p>Some text in a paragraph:</p><pre dir="ltr"><code>console.log('test')</code></pre>"`
);
});
12 changes: 6 additions & 6 deletions packages/starlight/__tests__/remark-rehype/rehype-tabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('tab items are processed', () => {
const { panels, html } = processPanels(input);

expect(html).toMatchInlineSnapshot(
'"<section id=\\"tab-panel-0\\" aria-labelledby=\\"tab-0\\" role=\\"tabpanel\\" tabindex=\\"0\\"><p>Random paragraph</p></section>"'
`"<section id="tab-panel-0" aria-labelledby="tab-0" role="tabpanel" tabindex="0"><p>Random paragraph</p></section>"`
);
expect(panels).toHaveLength(1);
expect(panels?.[0]?.label).toBe(label);
Expand All @@ -43,14 +43,14 @@ test('only first item is not hidden', () => {

expect(panels).toHaveLength(3);
expect(html).toMatchInlineSnapshot(
'"<section id=\\"tab-panel-1\\" aria-labelledby=\\"tab-1\\" role=\\"tabpanel\\" tabindex=\\"0\\"><div>One</div></section><section id=\\"tab-panel-2\\" aria-labelledby=\\"tab-2\\" role=\\"tabpanel\\" tabindex=\\"0\\" hidden><div>Two</div></section><section id=\\"tab-panel-3\\" aria-labelledby=\\"tab-3\\" role=\\"tabpanel\\" tabindex=\\"0\\" hidden><div>Three</div></section>"'
`"<section id="tab-panel-1" aria-labelledby="tab-1" role="tabpanel" tabindex="0"><div>One</div></section><section id="tab-panel-2" aria-labelledby="tab-2" role="tabpanel" tabindex="0" hidden><div>Two</div></section><section id="tab-panel-3" aria-labelledby="tab-3" role="tabpanel" tabindex="0" hidden><div>Three</div></section>"`
);
const sections = extractSections(html);
expect(sections).toMatchInlineSnapshot(`
[
"<section id=\\"tab-panel-1\\" aria-labelledby=\\"tab-1\\" role=\\"tabpanel\\" tabindex=\\"0\\"><div>One</div></section>",
"<section id=\\"tab-panel-2\\" aria-labelledby=\\"tab-2\\" role=\\"tabpanel\\" tabindex=\\"0\\" hidden><div>Two</div></section>",
"<section id=\\"tab-panel-3\\" aria-labelledby=\\"tab-3\\" role=\\"tabpanel\\" tabindex=\\"0\\" hidden><div>Three</div></section>",
"<section id="tab-panel-1" aria-labelledby="tab-1" role="tabpanel" tabindex="0"><div>One</div></section>",
"<section id="tab-panel-2" aria-labelledby="tab-2" role="tabpanel" tabindex="0" hidden><div>Two</div></section>",
"<section id="tab-panel-3" aria-labelledby="tab-3" role="tabpanel" tabindex="0" hidden><div>Three</div></section>",
]
`);
expect(sections.map((section) => section.includes('hidden'))).toEqual([false, true, true]);
Expand Down Expand Up @@ -82,7 +82,7 @@ test('applies tabindex="0" to tab items without focusable content', () => {
].join('');
const { html } = processPanels(input);
expect(html).toMatchInlineSnapshot(
'"<section id=\\"tab-panel-7\\" aria-labelledby=\\"tab-7\\" role=\\"tabpanel\\"><div><a href=\\"/home/\\">Home</a></div></section><section id=\\"tab-panel-8\\" aria-labelledby=\\"tab-8\\" role=\\"tabpanel\\" tabindex=\\"0\\" hidden><div>Plain text</div></section><section id=\\"tab-panel-9\\" aria-labelledby=\\"tab-9\\" role=\\"tabpanel\\" hidden><div><p><span><input type=\\"text\\"></span></p></div></section>"'
`"<section id="tab-panel-7" aria-labelledby="tab-7" role="tabpanel"><div><a href="/home/">Home</a></div></section><section id="tab-panel-8" aria-labelledby="tab-8" role="tabpanel" tabindex="0" hidden><div>Plain text</div></section><section id="tab-panel-9" aria-labelledby="tab-9" role="tabpanel" hidden><div><p><span><input type="text"></span></p></div></section>"`
);
const sections = extractSections(html);
expect(sections[0]).not.includes('tabindex="0"');
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@
"devDependencies": {
"@astrojs/markdown-remark": "^4.0.1",
"@types/node": "^18.16.19",
"@vitest/coverage-v8": "^0.33.0",
"@vitest/coverage-v8": "^1.2.2",
"astro": "^4.2.1",
"vitest": "^0.33.0"
"vitest": "^1.2.2"
},
"dependencies": {
"@astrojs/mdx": "^2.0.4",
Expand Down
12 changes: 7 additions & 5 deletions packages/starlight/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export default defineConfig({
// Main integration entrypoint — don’t think we’re able to test this directly currently.
'index.ts',
],
thresholdAutoUpdate: true,
lines: 80.11,
functions: 93.61,
branches: 91.23,
statements: 80.11,
thresholds: {
autoUpdate: true,
lines: 80.11,
functions: 93.61,
branches: 91.23,
statements: 80.11,
},
},
},
});
16 changes: 8 additions & 8 deletions packages/tailwind/__tests__/tailwind.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('@tailwind base;', async () => {
--tw-content: ;
}
:root {
--sl-font: ui-sans-serif, system-ui, sans-serif, \\"Apple Color Emoji\\", \\"Segoe UI Emoji\\", \\"Segoe UI Symbol\\", \\"Noto Color Emoji\\";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \\"Liberation Mono\\", \\"Courier New\\", monospace;
--sl-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--sl-color-white: #fff;
--sl-color-gray-1: #e5e7eb;
--sl-color-gray-2: #d1d5db;
Expand All @@ -53,7 +53,7 @@ describe('@tailwind base;', async () => {
--sl-color-accent: #4f46e5;
--sl-color-accent-high: #c7d2fe;
}
:root[data-theme=\\"light\\"] {
:root[data-theme="light"] {
--sl-color-white: #111827;
--sl-color-gray-1: #1f2937;
--sl-color-gray-2: #374151;
Expand Down Expand Up @@ -107,8 +107,8 @@ describe('@tailwind base;', async () => {
--tw-content: ;
}
:root {
--sl-font: ui-sans-serif, system-ui, sans-serif, \\"Apple Color Emoji\\", \\"Segoe UI Emoji\\", \\"Segoe UI Symbol\\", \\"Noto Color Emoji\\";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \\"Liberation Mono\\", \\"Courier New\\", monospace;
--sl-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--sl-color-white: #fff;
--sl-color-gray-1: #e5e7eb;
--sl-color-gray-2: #d1d5db;
Expand All @@ -121,7 +121,7 @@ describe('@tailwind base;', async () => {
--sl-color-accent: #4f46e5;
--sl-color-accent-high: #c7d2fe;
}
:root[data-theme=\\"light\\"] {
:root[data-theme="light"] {
--sl-color-white: #111827;
--sl-color-gray-1: #1f2937;
--sl-color-gray-2: #374151;
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('@tailwind utilities;', () => {
});
expect(utils).includes('[data-theme="dark"] .dark');
expect(utils).toMatchInlineSnapshot(`
":is([data-theme=\\"dark\\"] .dark\\\\:text-red-50) {
":is([data-theme="dark"] .dark\\:text-red-50) {
--tw-text-opacity: 1;
color: rgb(254 242 242 / var(--tw-text-opacity))
}"
Expand All @@ -258,7 +258,7 @@ test('warns when a prefix of "sl-" is set', async () => {
await generatePluginCss({ config: { prefix: 'sl-' } });
expect(warn).toBeCalledTimes(1);
expect(warn.mock.lastCall?.[0]).toMatchInlineSnapshot(`
"A Tailwind prefix of \\"sl-\\" will clash with Starlight’s built-in styles.
"A Tailwind prefix of "sl-" will clash with Starlight’s built-in styles.
Please set a different prefix in your Tailwind config file."
`);
warn.mockRestore();
Expand Down
4 changes: 2 additions & 2 deletions packages/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@vitest/coverage-v8": "^0.33.0",
"@vitest/coverage-v8": "^1.2.2",
"postcss": "^8.4.33",
"vitest": "^0.33.0"
"vitest": "^1.2.2"
},
"peerDependencies": {
"@astrojs/starlight": ">=0.9.0",
Expand Down
Loading

0 comments on commit c5f4a71

Please sign in to comment.