mirror of https://github.com/sveltejs/svelte
* Add some tests to avoid regression * Add runes test and remove extra testspull/10008/head
parent
b31946eb08
commit
bd34367660
@ -0,0 +1,44 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `
|
||||||
|
<p>1</p>
|
||||||
|
<p>2</p>
|
||||||
|
<p>3</p>
|
||||||
|
<p>4</p>
|
||||||
|
<p>5</p>
|
||||||
|
<p>6</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>6</p>
|
||||||
|
<p></p>
|
||||||
|
<p></p>
|
||||||
|
|
||||||
|
<button>Click me!</button>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const clickEvent = new window.Event('click', { bubbles: true });
|
||||||
|
await button?.dispatchEvent(clickEvent);
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<p>7</p>
|
||||||
|
<p>8</p>
|
||||||
|
<p>9</p>
|
||||||
|
<p>10</p>
|
||||||
|
<p>11</p>
|
||||||
|
<p>12</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>12</p>
|
||||||
|
<p>14</p>
|
||||||
|
<p>15</p>
|
||||||
|
|
||||||
|
<button>Click me!</button>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,42 @@
|
|||||||
|
<script>
|
||||||
|
import { get, writable } from 'svelte/store'
|
||||||
|
|
||||||
|
let bagOlStores = writable([1, 2, 3, writable(4), writable(5), writable(6)]);
|
||||||
|
|
||||||
|
let firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore;
|
||||||
|
([firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore] = $bagOlStores);
|
||||||
|
|
||||||
|
function changeStores() {
|
||||||
|
$bagOlStores = ([
|
||||||
|
firstNonStore,
|
||||||
|
secondNonStore,
|
||||||
|
thirdNonStore,
|
||||||
|
firstStore,
|
||||||
|
$secondStore,
|
||||||
|
thirdStore
|
||||||
|
] = [
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
writable(10),
|
||||||
|
11,
|
||||||
|
writable(12),
|
||||||
|
writable(14),
|
||||||
|
writable(15)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{firstNonStore}</p>
|
||||||
|
<p>{secondNonStore}</p>
|
||||||
|
<p>{thirdNonStore}</p>
|
||||||
|
<p>{$firstStore}</p>
|
||||||
|
<p>{$secondStore}</p>
|
||||||
|
<p>{$thirdStore}</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>{get($bagOlStores[5])}</p>
|
||||||
|
<p>{get($bagOlStores[6])}</p>
|
||||||
|
<p>{get($bagOlStores[7])}</p>
|
||||||
|
|
||||||
|
<button on:click={changeStores}>Click me!</button>
|
@ -0,0 +1,44 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `
|
||||||
|
<p>1</p>
|
||||||
|
<p>2</p>
|
||||||
|
<p>3</p>
|
||||||
|
<p>4</p>
|
||||||
|
<p>5</p>
|
||||||
|
<p>6</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>4</p>
|
||||||
|
<p>5</p>
|
||||||
|
<p>6</p>
|
||||||
|
|
||||||
|
<button>Click me!</button>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const clickEvent = new window.Event('click', { bubbles: true });
|
||||||
|
await button?.dispatchEvent(clickEvent);
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<p>7</p>
|
||||||
|
<p>8</p>
|
||||||
|
<p>9</p>
|
||||||
|
<p>10</p>
|
||||||
|
<p>11</p>
|
||||||
|
<p>12</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>14</p>
|
||||||
|
<p>13</p>
|
||||||
|
<p>12</p>
|
||||||
|
|
||||||
|
<button>Click me!</button>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,48 @@
|
|||||||
|
<script>
|
||||||
|
import { get, writable } from 'svelte/store'
|
||||||
|
|
||||||
|
let bagOlStores = writable({
|
||||||
|
firstNonStore: 1,
|
||||||
|
secondNonStore: 2,
|
||||||
|
thirdNonStore: 3,
|
||||||
|
firstStore: writable(4),
|
||||||
|
secondStore: writable(5),
|
||||||
|
thirdStore: writable(6)
|
||||||
|
});
|
||||||
|
|
||||||
|
let { firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore } = $bagOlStores;
|
||||||
|
|
||||||
|
function changeStores() {
|
||||||
|
$bagOlStores = ({
|
||||||
|
thirdStore,
|
||||||
|
$secondStore,
|
||||||
|
$firstStore,
|
||||||
|
firstNonStore,
|
||||||
|
secondNonStore,
|
||||||
|
thirdNonStore,
|
||||||
|
} = {
|
||||||
|
firstNonStore: 7,
|
||||||
|
secondNonStore: 8,
|
||||||
|
thirdNonStore: 9,
|
||||||
|
$firstStore: 10,
|
||||||
|
$secondStore: 11,
|
||||||
|
firstStore: writable(14),
|
||||||
|
secondStore: writable(13),
|
||||||
|
thirdStore: writable(12)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{firstNonStore}</p>
|
||||||
|
<p>{secondNonStore}</p>
|
||||||
|
<p>{thirdNonStore}</p>
|
||||||
|
<p>{$firstStore}</p>
|
||||||
|
<p>{$secondStore}</p>
|
||||||
|
<p>{$thirdStore}</p>
|
||||||
|
|
||||||
|
<h1>Bag'ol stores</h1>
|
||||||
|
<p>{get($bagOlStores.firstStore)}</p>
|
||||||
|
<p>{get($bagOlStores.secondStore)}</p>
|
||||||
|
<p>{get($bagOlStores.thirdStore)}</p>
|
||||||
|
|
||||||
|
<button on:click={changeStores}>Click me!</button>
|
@ -0,0 +1,38 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `
|
||||||
|
<button>Update</button>
|
||||||
|
|
||||||
|
<p>0</p>
|
||||||
|
<p>b</p>
|
||||||
|
<p>true</p>
|
||||||
|
<p>0</p>
|
||||||
|
<p>10</p>
|
||||||
|
<p>12</p>
|
||||||
|
<p>15</p>
|
||||||
|
<p>16</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const clickEvent = new window.Event('click', { bubbles: true });
|
||||||
|
await button?.dispatchEvent(clickEvent);
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>Update</button>
|
||||||
|
|
||||||
|
<p>5</p>
|
||||||
|
<p>d</p>
|
||||||
|
<p>false</p>
|
||||||
|
<p>3</p>
|
||||||
|
<p>100</p>
|
||||||
|
<p>120</p>
|
||||||
|
<p>25</p>
|
||||||
|
<p>26</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,23 @@
|
|||||||
|
<script>
|
||||||
|
let a = $state(0);
|
||||||
|
let b = $state("b");
|
||||||
|
let c = $state(true);
|
||||||
|
let d = $state([]);
|
||||||
|
let e = $state({ x: 10, y: 12 });
|
||||||
|
let f = $state({ w: 15, v: 16 });
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
({ d, e, g: [f.w, f.v] } = { d: ([a, b, c] = [5, "d", false]), e: { x: 100, y: 120 }, g: [25, 26] });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={change}>Update</button>
|
||||||
|
|
||||||
|
<p>{a}</p>
|
||||||
|
<p>{b}</p>
|
||||||
|
<p>{c}</p>
|
||||||
|
<p>{d.length}</p>
|
||||||
|
<p>{e.x}</p>
|
||||||
|
<p>{e.y}</p>
|
||||||
|
<p>{f.w}</p>
|
||||||
|
<p>{f.v}</p>
|
Loading…
Reference in new issue