mirror of https://github.com/sveltejs/svelte
chore: add xhtml tests (#17597)
* add xhtml tests * unused * tweak * more tests * tweak * we don't need to actually check the HTML - if it's malformed in SSR or mount, it will throw * same here * unused, so we can revert this * and this --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/17648/head
parent
bb00d5b6e7
commit
9749ee869c
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
<div foo=bar></div>
|
||||||
|
<div foo='bar baz'></div>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<ul><li><li></ul>
|
||||||
|
<dl><dt><dd><dd></dl>
|
||||||
|
<p><p><div></div>
|
||||||
|
<ruby><rp><rt><rt></ruby>
|
||||||
|
<select><option><optgroup><optgroup></select>
|
||||||
|
<table><thead><tbody><tfoot><tbody><tr><td><th></tr><tr></table>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
skip: true
|
||||||
|
});
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<input disabled hidden>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{#each [1,2] as i}{i}{/each}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['client'],
|
||||||
|
test({ assert, target }) {
|
||||||
|
assert.htmlEqual(target.innerHTML, `<div>div</div>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let elem = $state();
|
||||||
|
let nodeName = $derived(elem?.nodeName);
|
||||||
|
</script>
|
||||||
|
<div bind:this={elem}>{nodeName}</div>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<area alt="">
|
||||||
|
<base>
|
||||||
|
<br>
|
||||||
|
<col>
|
||||||
|
<embed>
|
||||||
|
<hr>
|
||||||
|
<img alt="">
|
||||||
|
<input>
|
||||||
|
<keygen>
|
||||||
|
<link>
|
||||||
|
<meta>
|
||||||
|
<param>
|
||||||
|
<source>
|
||||||
|
<track>
|
||||||
|
<wbr>
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
// @vitest-environment vitest-xhtml-environment.ts
|
||||||
|
|
||||||
|
import { runtime_suite, ok } from '../runtime-legacy/shared';
|
||||||
|
|
||||||
|
const { test, run } = runtime_suite(true);
|
||||||
|
|
||||||
|
export { test, ok };
|
||||||
|
|
||||||
|
await run(__dirname);
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
import { type Environment, builtinEnvironments } from 'vitest/environments';
|
||||||
|
|
||||||
|
const xhtml_page = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>`;
|
||||||
|
|
||||||
|
export default <Environment>{
|
||||||
|
name: 'jsdom-xhtml',
|
||||||
|
transformMode: 'web',
|
||||||
|
setup(global, { jsdom = {} }) {
|
||||||
|
return builtinEnvironments.jsdom.setup(global, {
|
||||||
|
jsdom: {
|
||||||
|
...jsdom,
|
||||||
|
html: xhtml_page,
|
||||||
|
contentType: 'application/xhtml+xml'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in new issue