Skip to content

Commit bd34367

Browse files
authored
fix: Add some tests to avoid regression on #8559 (#9956)
* Add some tests to avoid regression * Add runes test and remove extra tests
1 parent b31946e commit bd34367

File tree

6 files changed

+239
-0
lines changed

6 files changed

+239
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `
5+
<p>1</p>
6+
<p>2</p>
7+
<p>3</p>
8+
<p>4</p>
9+
<p>5</p>
10+
<p>6</p>
11+
12+
<h1>Bag'ol stores</h1>
13+
<p>6</p>
14+
<p></p>
15+
<p></p>
16+
17+
<button>Click me!</button>
18+
`,
19+
20+
async test({ assert, target, window }) {
21+
const button = target.querySelector('button');
22+
const clickEvent = new window.Event('click', { bubbles: true });
23+
await button?.dispatchEvent(clickEvent);
24+
25+
assert.htmlEqual(
26+
target.innerHTML,
27+
`
28+
<p>7</p>
29+
<p>8</p>
30+
<p>9</p>
31+
<p>10</p>
32+
<p>11</p>
33+
<p>12</p>
34+
35+
<h1>Bag'ol stores</h1>
36+
<p>12</p>
37+
<p>14</p>
38+
<p>15</p>
39+
40+
<button>Click me!</button>
41+
`
42+
);
43+
}
44+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script>
2+
import { get, writable } from 'svelte/store'
3+
4+
let bagOlStores = writable([1, 2, 3, writable(4), writable(5), writable(6)]);
5+
6+
let firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore;
7+
([firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore] = $bagOlStores);
8+
9+
function changeStores() {
10+
$bagOlStores = ([
11+
firstNonStore,
12+
secondNonStore,
13+
thirdNonStore,
14+
firstStore,
15+
$secondStore,
16+
thirdStore
17+
] = [
18+
7,
19+
8,
20+
9,
21+
writable(10),
22+
11,
23+
writable(12),
24+
writable(14),
25+
writable(15)
26+
]);
27+
}
28+
</script>
29+
30+
<p>{firstNonStore}</p>
31+
<p>{secondNonStore}</p>
32+
<p>{thirdNonStore}</p>
33+
<p>{$firstStore}</p>
34+
<p>{$secondStore}</p>
35+
<p>{$thirdStore}</p>
36+
37+
<h1>Bag'ol stores</h1>
38+
<p>{get($bagOlStores[5])}</p>
39+
<p>{get($bagOlStores[6])}</p>
40+
<p>{get($bagOlStores[7])}</p>
41+
42+
<button on:click={changeStores}>Click me!</button>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `
5+
<p>1</p>
6+
<p>2</p>
7+
<p>3</p>
8+
<p>4</p>
9+
<p>5</p>
10+
<p>6</p>
11+
12+
<h1>Bag'ol stores</h1>
13+
<p>4</p>
14+
<p>5</p>
15+
<p>6</p>
16+
17+
<button>Click me!</button>
18+
`,
19+
20+
async test({ assert, target, window }) {
21+
const button = target.querySelector('button');
22+
const clickEvent = new window.Event('click', { bubbles: true });
23+
await button?.dispatchEvent(clickEvent);
24+
25+
assert.htmlEqual(
26+
target.innerHTML,
27+
`
28+
<p>7</p>
29+
<p>8</p>
30+
<p>9</p>
31+
<p>10</p>
32+
<p>11</p>
33+
<p>12</p>
34+
35+
<h1>Bag'ol stores</h1>
36+
<p>14</p>
37+
<p>13</p>
38+
<p>12</p>
39+
40+
<button>Click me!</button>
41+
`
42+
);
43+
}
44+
});
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script>
2+
import { get, writable } from 'svelte/store'
3+
4+
let bagOlStores = writable({
5+
firstNonStore: 1,
6+
secondNonStore: 2,
7+
thirdNonStore: 3,
8+
firstStore: writable(4),
9+
secondStore: writable(5),
10+
thirdStore: writable(6)
11+
});
12+
13+
let { firstNonStore, secondNonStore, thirdNonStore, firstStore, secondStore, thirdStore } = $bagOlStores;
14+
15+
function changeStores() {
16+
$bagOlStores = ({
17+
thirdStore,
18+
$secondStore,
19+
$firstStore,
20+
firstNonStore,
21+
secondNonStore,
22+
thirdNonStore,
23+
} = {
24+
firstNonStore: 7,
25+
secondNonStore: 8,
26+
thirdNonStore: 9,
27+
$firstStore: 10,
28+
$secondStore: 11,
29+
firstStore: writable(14),
30+
secondStore: writable(13),
31+
thirdStore: writable(12)
32+
});
33+
}
34+
</script>
35+
36+
<p>{firstNonStore}</p>
37+
<p>{secondNonStore}</p>
38+
<p>{thirdNonStore}</p>
39+
<p>{$firstStore}</p>
40+
<p>{$secondStore}</p>
41+
<p>{$thirdStore}</p>
42+
43+
<h1>Bag'ol stores</h1>
44+
<p>{get($bagOlStores.firstStore)}</p>
45+
<p>{get($bagOlStores.secondStore)}</p>
46+
<p>{get($bagOlStores.thirdStore)}</p>
47+
48+
<button on:click={changeStores}>Click me!</button>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `
5+
<button>Update</button>
6+
7+
<p>0</p>
8+
<p>b</p>
9+
<p>true</p>
10+
<p>0</p>
11+
<p>10</p>
12+
<p>12</p>
13+
<p>15</p>
14+
<p>16</p>
15+
`,
16+
17+
async test({ assert, target, window }) {
18+
const button = target.querySelector('button');
19+
const clickEvent = new window.Event('click', { bubbles: true });
20+
await button?.dispatchEvent(clickEvent);
21+
22+
assert.htmlEqual(
23+
target.innerHTML,
24+
`
25+
<button>Update</button>
26+
27+
<p>5</p>
28+
<p>d</p>
29+
<p>false</p>
30+
<p>3</p>
31+
<p>100</p>
32+
<p>120</p>
33+
<p>25</p>
34+
<p>26</p>
35+
`
36+
);
37+
}
38+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script>
2+
let a = $state(0);
3+
let b = $state("b");
4+
let c = $state(true);
5+
let d = $state([]);
6+
let e = $state({ x: 10, y: 12 });
7+
let f = $state({ w: 15, v: 16 });
8+
9+
function change() {
10+
({ d, e, g: [f.w, f.v] } = { d: ([a, b, c] = [5, "d", false]), e: { x: 100, y: 120 }, g: [25, 26] });
11+
}
12+
</script>
13+
14+
<button on:click={change}>Update</button>
15+
16+
<p>{a}</p>
17+
<p>{b}</p>
18+
<p>{c}</p>
19+
<p>{d.length}</p>
20+
<p>{e.x}</p>
21+
<p>{e.y}</p>
22+
<p>{f.w}</p>
23+
<p>{f.v}</p>

0 commit comments

Comments
 (0)