From 6b229da58b1c5690d8c0739a917114cbaa6c53ff Mon Sep 17 00:00:00 2001 From: baseballyama Date: Thu, 5 May 2022 14:09:36 +0900 Subject: [PATCH] add test with svelte:self --- .../Slider.svelte | 29 +++++++ .../_config.js | 71 ++++++++++++++++ .../main.svelte | 32 +++++++ .../Slider1.svelte | 27 ++++++ .../Slider2.svelte | 27 ++++++ .../_config.js | 47 +++++++++++ .../main.svelte | 16 ++++ .../Slider1.svelte | 27 ++++++ .../Slider2.svelte | 27 ++++++ .../_config.js | 84 +++++++++++++++++++ .../main.svelte | 20 +++++ 11 files changed, 407 insertions(+) create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/Slider.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/_config.js create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/main.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider1.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider2.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties/_config.js create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties/main.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider1.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider2.svelte create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/_config.js create mode 100644 test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/main.svelte diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/Slider.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/Slider.svelte new file mode 100644 index 0000000000..210e34cbe9 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/Slider.svelte @@ -0,0 +1,29 @@ + + +
+

Slider

+ Track +
+ +{#if count === 0} + +{/if} + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/_config.js b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/_config.js new file mode 100644 index 0000000000..c7d1369edc --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/_config.js @@ -0,0 +1,71 @@ +export default { + props: { + railColor1: 'black', + trackColor1: 'red', + railColor2: 'green', + trackColor2: 'blue', + nestRailColor1: 'white', + nestTrackColor1: 'gray', + nestRailColor2: 'aqua', + nestTrackColor2: 'pink' + }, + html: ` +
+
+

Slider

+ Track +
+
+
+

Slider

+ Track +
+
+
+
+
+

Slider

+ Track +
+
+
+

Slider

+ Track +
+
+
+ `, + test({ component, assert, target }) { + component.railColor1 = 'yellow'; + component.trackColor2 = 'orange'; + component.nestRailColor1 = 'lime'; + component.nestTrackColor2 = 'gold'; + + assert.htmlEqual(target.innerHTML, ` +
+
+

Slider

+ Track +
+
+
+

Slider

+ Track +
+
+
+
+
+

Slider

+ Track +
+
+
+

Slider

+ Track +
+
+
+ `); + } +}; diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/main.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/main.svelte new file mode 100644 index 0000000000..69c31fff35 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties-dynamic/main.svelte @@ -0,0 +1,32 @@ + + + + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider1.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider1.svelte new file mode 100644 index 0000000000..20699ca853 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider1.svelte @@ -0,0 +1,27 @@ + + +
+

Slider1

+ Track +
+ +{#if count === 0} + +{/if} + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider2.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider2.svelte new file mode 100644 index 0000000000..ce799c4dc0 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/Slider2.svelte @@ -0,0 +1,27 @@ + + +
+

Slider2

+ Track +
+ +{#if count === 0} + +{/if} + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/_config.js b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/_config.js new file mode 100644 index 0000000000..f3023db3c4 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/_config.js @@ -0,0 +1,47 @@ +export default { + props: {}, + html: ` +
+
+

Slider1

Track +
+
+
+

Slider1

Track
+
+
+
+
+

Slider2

Track +
+
+
+

Slider2

Track +
+
+
+ `, + test({ target, window, assert }) { + const railColor1 = target.querySelector('#component1 p'); + const trackColor1 = target.querySelector('#component1 span'); + const railColor2 = target.querySelector('#component2 p'); + const trackColor2 = target.querySelector('#component2 span'); + const nestRailColor1 = target.querySelector('#nest-component1 p'); + const nestTrackColor1 = target.querySelector('#nest-component1 span'); + const nestRailColor2 = target.querySelector('#nest-component2 p'); + const nestTrackColor2 = target.querySelector('#nest-component2 span'); + + assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); + assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); + assert.equal(railColor1.textContent, 'Slider1'); + assert.equal(railColor2.textContent, 'Slider2'); + assert.equal(nestRailColor1.textContent, 'Slider1'); + assert.equal(nestRailColor2.textContent, 'Slider2'); + } +}; diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/main.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/main.svelte new file mode 100644 index 0000000000..1a4ed02959 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties/main.svelte @@ -0,0 +1,16 @@ + + + + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider1.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider1.svelte new file mode 100644 index 0000000000..20699ca853 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider1.svelte @@ -0,0 +1,27 @@ + + +
+

Slider1

+ Track +
+ +{#if count === 0} + +{/if} + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider2.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider2.svelte new file mode 100644 index 0000000000..ce799c4dc0 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/Slider2.svelte @@ -0,0 +1,27 @@ + + +
+

Slider2

+ Track +
+ +{#if count === 0} + +{/if} + + diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/_config.js b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/_config.js new file mode 100644 index 0000000000..5efc8f0c70 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/_config.js @@ -0,0 +1,84 @@ +export default { + props: { + componentName: 'Slider1' + }, + html: ` +
+
+

Slider1

Track +
+
+
+

Slider1

Track
+
+
+
+
+

Slider1

Track +
+
+
+

Slider1

Track +
+
+
+ `, + test({ target, window, assert, component }) { + + function assert_slider_1() { + const railColor1 = target.querySelector('#component1 p'); + const trackColor1 = target.querySelector('#component1 span'); + const railColor2 = target.querySelector('#component2 p'); + const trackColor2 = target.querySelector('#component2 span'); + const nestRailColor1 = target.querySelector('#nest-component1 p'); + const nestTrackColor1 = target.querySelector('#nest-component1 span'); + const nestRailColor2 = target.querySelector('#nest-component2 p'); + const nestTrackColor2 = target.querySelector('#nest-component2 span'); + + assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); + assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 0, 255)'); + assert.equal(railColor1.textContent, 'Slider1'); + assert.equal(railColor2.textContent, 'Slider1'); + assert.equal(nestRailColor1.textContent, 'Slider1'); + assert.equal(nestRailColor2.textContent, 'Slider1'); + } + + function assert_slider_2() { + const railColor1 = target.querySelector('#component1 p'); + const trackColor1 = target.querySelector('#component1 span'); + const railColor2 = target.querySelector('#component2 p'); + const trackColor2 = target.querySelector('#component2 span'); + const nestRailColor1 = target.querySelector('#nest-component1 p'); + const nestTrackColor1 = target.querySelector('#nest-component1 span'); + const nestRailColor2 = target.querySelector('#nest-component2 p'); + const nestTrackColor2 = target.querySelector('#nest-component2 span'); + + assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 255, 255)'); + assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); + assert.equal(railColor1.textContent, 'Slider2'); + assert.equal(railColor2.textContent, 'Slider2'); + assert.equal(nestRailColor1.textContent, 'Slider2'); + assert.equal(nestRailColor2.textContent, 'Slider2'); + } + + assert_slider_1(); + component.componentName = 'Slider2'; + assert_slider_2(); + component.componentName = undefined; + assert.equal(window.document.querySelector('div'), null); + component.componentName = 'Slider1'; + assert_slider_1(); + } +}; diff --git a/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/main.svelte b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/main.svelte new file mode 100644 index 0000000000..2c6d05dc25 --- /dev/null +++ b/test/runtime-puppeteer/samples/svelte-self-css-custom-properties2/main.svelte @@ -0,0 +1,20 @@ + + + + +