mirror of https://github.com/sveltejs/svelte
parent
eab690d31a
commit
1b19c96c43
@ -0,0 +1,12 @@
|
||||
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>
|
||||
`
|
||||
});
|
||||
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
import { readable } from 'svelte/store'
|
||||
|
||||
let firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore;
|
||||
|
||||
({ firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore } = {
|
||||
firstNonStore: 1,
|
||||
secondNonStore: 2,
|
||||
thirdNonStore: 3,
|
||||
firstStore: readable(4),
|
||||
fourthNonStore: 5,
|
||||
secondStore: readable(6)
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>{firstNonStore}</p>
|
||||
<p>{secondNonStore}</p>
|
||||
<p>{thirdNonStore}</p>
|
||||
<p>{$firstStore}</p>
|
||||
<p>{fourthNonStore}</p>
|
||||
<p>{$secondStore}</p>
|
||||
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: 'true'
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import { readable } from 'svelte/store'
|
||||
|
||||
let store, nonStore;
|
||||
|
||||
([nonStore, store] = [true, readable(true)]);
|
||||
</script>
|
||||
|
||||
{#if $store}
|
||||
{nonStore}
|
||||
{/if}
|
||||
@ -0,0 +1,12 @@
|
||||
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>
|
||||
`
|
||||
});
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { readable } from 'svelte/store'
|
||||
|
||||
let firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore;
|
||||
|
||||
([firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore] = [1, 2, 3, readable(4), 5, readable(6)]);
|
||||
</script>
|
||||
|
||||
<p>{firstNonStore}</p>
|
||||
<p>{secondNonStore}</p>
|
||||
<p>{thirdNonStore}</p>
|
||||
<p>{$firstStore}</p>
|
||||
<p>{fourthNonStore}</p>
|
||||
<p>{$secondStore}</p>
|
||||
@ -0,0 +1,12 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<p>7</p>
|
||||
<p>8</p>
|
||||
<p>9</p>
|
||||
<p>10</p>
|
||||
<p>11</p>
|
||||
<p>12</p>
|
||||
`
|
||||
});
|
||||
@ -0,0 +1,29 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
let { firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore } = {
|
||||
firstNonStore: 1,
|
||||
secondNonStore: 2,
|
||||
thirdNonStore: 3,
|
||||
firstStore: writable(4),
|
||||
fourthNonStore: 5,
|
||||
secondStore: writable(6)
|
||||
};
|
||||
|
||||
({ firstNonStore, secondNonStore, thirdNonStore, fourthNonStore, firstStore, $secondStore } = {
|
||||
firstNonStore: 7,
|
||||
secondNonStore: 8,
|
||||
thirdNonStore: 9,
|
||||
fourthNonStore: 11,
|
||||
firstStore: writable(10),
|
||||
$secondStore: 12
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>{firstNonStore}</p>
|
||||
<p>{secondNonStore}</p>
|
||||
<p>{thirdNonStore}</p>
|
||||
<p>{$firstStore}</p>
|
||||
<p>{fourthNonStore}</p>
|
||||
<p>{$secondStore}</p>
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<p>7</p>
|
||||
<p>8</p>
|
||||
<p>9</p>
|
||||
<p>10</p>
|
||||
<p>11</p>
|
||||
<p>12</p>
|
||||
`
|
||||
});
|
||||
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
let { firstNonStore, secondNonStore, thirdNonStore, firstStore, fourthNonStore, secondStore } = {
|
||||
firstNonStore: 1,
|
||||
secondNonStore: 2,
|
||||
thirdNonStore: 3,
|
||||
firstStore: writable(4),
|
||||
fourthNonStore: 5,
|
||||
secondStore: writable(6)
|
||||
};
|
||||
|
||||
([firstNonStore, secondNonStore, thirdNonStore, fourthNonStore, $firstStore, $secondStore] = [7, 8, 9, 11, 10, 12]);
|
||||
</script>
|
||||
|
||||
<p>{firstNonStore}</p>
|
||||
<p>{secondNonStore}</p>
|
||||
<p>{thirdNonStore}</p>
|
||||
<p>{$firstStore}</p>
|
||||
<p>{fourthNonStore}</p>
|
||||
<p>{$secondStore}</p>
|
||||
|
||||
@ -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,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,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: 'true'
|
||||
});
|
||||
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import { readable } from 'svelte/store'
|
||||
|
||||
let store, nonStore;
|
||||
|
||||
const getExports = () => ({ nonStore: true, store: readable(true) });
|
||||
|
||||
({ nonStore, store } = getExports());
|
||||
</script>
|
||||
|
||||
{#if $store}
|
||||
{nonStore}
|
||||
{/if}
|
||||
Loading…
Reference in new issue