From a2cb4a87a07d62228a78e76feb7638102a35ac8c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 7 Dec 2016 11:53:15 -0500 Subject: [PATCH] add SSR tests --- test/ssr/attribute-boolean/_actual.html | 1 + test/ssr/attribute-boolean/_expected.html | 1 + test/ssr/attribute-boolean/main.html | 1 + test/ssr/attribute-dynamic/_actual.html | 1 + test/ssr/attribute-dynamic/_expected.html | 1 + test/ssr/attribute-dynamic/data.json | 4 ++ test/ssr/attribute-dynamic/main.html | 1 + test/ssr/attribute-static/_actual.html | 1 + test/ssr/attribute-static/_expected.html | 1 + test/ssr/attribute-static/main.html | 1 + test/ssr/component-data-dynamic/Widget.html | 4 ++ test/ssr/component-data-dynamic/_actual.html | 4 ++ .../ssr/component-data-dynamic/_expected.html | 4 ++ test/ssr/component-data-dynamic/data.json | 6 +++ test/ssr/component-data-dynamic/main.html | 11 +++++ test/ssr/component-data-empty/Widget.html | 1 + test/ssr/component-data-empty/_actual.html | 1 + test/ssr/component-data-empty/_expected.html | 1 + test/ssr/component-data-empty/main.html | 11 +++++ test/ssr/component-data-static/Widget.html | 2 + test/ssr/component-data-static/_actual.html | 2 + test/ssr/component-data-static/_expected.html | 2 + test/ssr/component-data-static/main.html | 11 +++++ test/ssr/component-yield/Widget.html | 11 +++++ test/ssr/component-yield/_actual.html | 1 + test/ssr/component-yield/_expected.html | 1 + test/ssr/component-yield/main.html | 17 ++++++++ test/ssr/component/Widget.html | 1 + test/ssr/component/_actual.html | 1 + test/ssr/component/_expected.html | 1 + test/ssr/component/main.html | 11 +++++ test/ssr/computed/_actual.html | 2 + test/ssr/computed/_expected.html | 2 + test/ssr/computed/data.json | 4 ++ test/ssr/computed/main.html | 11 +++++ test/ssr/default-data-override/_actual.html | 1 + test/ssr/default-data-override/_expected.html | 1 + test/ssr/default-data-override/data.json | 3 ++ test/ssr/default-data-override/main.html | 11 +++++ test/ssr/default-data/_actual.html | 1 + test/ssr/default-data/_expected.html | 1 + test/ssr/default-data/main.html | 11 +++++ test/ssr/dynamic-text/_actual.html | 1 + test/ssr/dynamic-text/_expected.html | 1 + test/ssr/dynamic-text/data.json | 3 ++ test/ssr/dynamic-text/main.html | 1 + test/ssr/each-block/_actual.html | 1 + test/ssr/each-block/_expected.html | 1 + test/ssr/each-block/data.json | 7 +++ test/ssr/each-block/main.html | 3 ++ test/ssr/helpers/_actual.html | 1 + test/ssr/helpers/_expected.html | 1 + test/ssr/helpers/main.html | 15 +++++++ test/ssr/if-block-false/_actual.html | 0 test/ssr/if-block-false/_expected.html | 0 test/ssr/if-block-false/data.json | 3 ++ test/ssr/if-block-false/main.html | 3 ++ test/ssr/if-block-true/_actual.html | 1 + test/ssr/if-block-true/_expected.html | 1 + test/ssr/if-block-true/data.json | 3 ++ test/ssr/if-block-true/main.html | 3 ++ test/ssr/static-div/_actual.html | 1 + test/ssr/static-div/_expected.html | 1 + test/ssr/static-div/main.html | 1 + test/ssr/static-text/_actual.html | 1 + test/ssr/static-text/_expected.html | 1 + test/ssr/static-text/main.html | 1 + test/test.js | 43 +++++++++++++++---- 68 files changed, 254 insertions(+), 9 deletions(-) create mode 100644 test/ssr/attribute-boolean/_actual.html create mode 100644 test/ssr/attribute-boolean/_expected.html create mode 100644 test/ssr/attribute-boolean/main.html create mode 100644 test/ssr/attribute-dynamic/_actual.html create mode 100644 test/ssr/attribute-dynamic/_expected.html create mode 100644 test/ssr/attribute-dynamic/data.json create mode 100644 test/ssr/attribute-dynamic/main.html create mode 100644 test/ssr/attribute-static/_actual.html create mode 100644 test/ssr/attribute-static/_expected.html create mode 100644 test/ssr/attribute-static/main.html create mode 100644 test/ssr/component-data-dynamic/Widget.html create mode 100644 test/ssr/component-data-dynamic/_actual.html create mode 100644 test/ssr/component-data-dynamic/_expected.html create mode 100644 test/ssr/component-data-dynamic/data.json create mode 100644 test/ssr/component-data-dynamic/main.html create mode 100644 test/ssr/component-data-empty/Widget.html create mode 100644 test/ssr/component-data-empty/_actual.html create mode 100644 test/ssr/component-data-empty/_expected.html create mode 100644 test/ssr/component-data-empty/main.html create mode 100644 test/ssr/component-data-static/Widget.html create mode 100644 test/ssr/component-data-static/_actual.html create mode 100644 test/ssr/component-data-static/_expected.html create mode 100644 test/ssr/component-data-static/main.html create mode 100644 test/ssr/component-yield/Widget.html create mode 100644 test/ssr/component-yield/_actual.html create mode 100644 test/ssr/component-yield/_expected.html create mode 100644 test/ssr/component-yield/main.html create mode 100644 test/ssr/component/Widget.html create mode 100644 test/ssr/component/_actual.html create mode 100644 test/ssr/component/_expected.html create mode 100644 test/ssr/component/main.html create mode 100644 test/ssr/computed/_actual.html create mode 100644 test/ssr/computed/_expected.html create mode 100644 test/ssr/computed/data.json create mode 100644 test/ssr/computed/main.html create mode 100644 test/ssr/default-data-override/_actual.html create mode 100644 test/ssr/default-data-override/_expected.html create mode 100644 test/ssr/default-data-override/data.json create mode 100644 test/ssr/default-data-override/main.html create mode 100644 test/ssr/default-data/_actual.html create mode 100644 test/ssr/default-data/_expected.html create mode 100644 test/ssr/default-data/main.html create mode 100644 test/ssr/dynamic-text/_actual.html create mode 100644 test/ssr/dynamic-text/_expected.html create mode 100644 test/ssr/dynamic-text/data.json create mode 100644 test/ssr/dynamic-text/main.html create mode 100644 test/ssr/each-block/_actual.html create mode 100644 test/ssr/each-block/_expected.html create mode 100644 test/ssr/each-block/data.json create mode 100644 test/ssr/each-block/main.html create mode 100644 test/ssr/helpers/_actual.html create mode 100644 test/ssr/helpers/_expected.html create mode 100644 test/ssr/helpers/main.html create mode 100644 test/ssr/if-block-false/_actual.html create mode 100644 test/ssr/if-block-false/_expected.html create mode 100644 test/ssr/if-block-false/data.json create mode 100644 test/ssr/if-block-false/main.html create mode 100644 test/ssr/if-block-true/_actual.html create mode 100644 test/ssr/if-block-true/_expected.html create mode 100644 test/ssr/if-block-true/data.json create mode 100644 test/ssr/if-block-true/main.html create mode 100644 test/ssr/static-div/_actual.html create mode 100644 test/ssr/static-div/_expected.html create mode 100644 test/ssr/static-div/main.html create mode 100644 test/ssr/static-text/_actual.html create mode 100644 test/ssr/static-text/_expected.html create mode 100644 test/ssr/static-text/main.html diff --git a/test/ssr/attribute-boolean/_actual.html b/test/ssr/attribute-boolean/_actual.html new file mode 100644 index 0000000000..c45ee39b0f --- /dev/null +++ b/test/ssr/attribute-boolean/_actual.html @@ -0,0 +1 @@ + diff --git a/test/ssr/attribute-boolean/main.html b/test/ssr/attribute-boolean/main.html new file mode 100644 index 0000000000..3ca3bfd9a8 --- /dev/null +++ b/test/ssr/attribute-boolean/main.html @@ -0,0 +1 @@ + diff --git a/test/ssr/attribute-dynamic/_actual.html b/test/ssr/attribute-dynamic/_actual.html new file mode 100644 index 0000000000..8960382913 --- /dev/null +++ b/test/ssr/attribute-dynamic/_actual.html @@ -0,0 +1 @@ +
aquamarine sans-serif
\ No newline at end of file diff --git a/test/ssr/attribute-dynamic/_expected.html b/test/ssr/attribute-dynamic/_expected.html new file mode 100644 index 0000000000..5d9e40d299 --- /dev/null +++ b/test/ssr/attribute-dynamic/_expected.html @@ -0,0 +1 @@ +
aquamarine sans-serif
diff --git a/test/ssr/attribute-dynamic/data.json b/test/ssr/attribute-dynamic/data.json new file mode 100644 index 0000000000..774a6ed7b1 --- /dev/null +++ b/test/ssr/attribute-dynamic/data.json @@ -0,0 +1,4 @@ +{ + "font": "sans-serif", + "color": "aquamarine" +} diff --git a/test/ssr/attribute-dynamic/main.html b/test/ssr/attribute-dynamic/main.html new file mode 100644 index 0000000000..18732ab91a --- /dev/null +++ b/test/ssr/attribute-dynamic/main.html @@ -0,0 +1 @@ +
{{color}} {{font}}
diff --git a/test/ssr/attribute-static/_actual.html b/test/ssr/attribute-static/_actual.html new file mode 100644 index 0000000000..f82d79e45a --- /dev/null +++ b/test/ssr/attribute-static/_actual.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/ssr/attribute-static/_expected.html b/test/ssr/attribute-static/_expected.html new file mode 100644 index 0000000000..3cb2e4b233 --- /dev/null +++ b/test/ssr/attribute-static/_expected.html @@ -0,0 +1 @@ +
diff --git a/test/ssr/attribute-static/main.html b/test/ssr/attribute-static/main.html new file mode 100644 index 0000000000..3cb2e4b233 --- /dev/null +++ b/test/ssr/attribute-static/main.html @@ -0,0 +1 @@ +
diff --git a/test/ssr/component-data-dynamic/Widget.html b/test/ssr/component-data-dynamic/Widget.html new file mode 100644 index 0000000000..43184b9ad8 --- /dev/null +++ b/test/ssr/component-data-dynamic/Widget.html @@ -0,0 +1,4 @@ +

foo: {{foo}}

+

baz: {{baz}} ({{typeof baz}})

+

qux: {{qux}}

+

quux: {{quux}}

diff --git a/test/ssr/component-data-dynamic/_actual.html b/test/ssr/component-data-dynamic/_actual.html new file mode 100644 index 0000000000..97800c17aa --- /dev/null +++ b/test/ssr/component-data-dynamic/_actual.html @@ -0,0 +1,4 @@ +

foo: lol

+

baz: 42 (number)

+

qux: this is a piece of string

+

quux: core

\ No newline at end of file diff --git a/test/ssr/component-data-dynamic/_expected.html b/test/ssr/component-data-dynamic/_expected.html new file mode 100644 index 0000000000..432cfba85a --- /dev/null +++ b/test/ssr/component-data-dynamic/_expected.html @@ -0,0 +1,4 @@ +

foo: lol

+

baz: 42 (number)

+

qux: this is a piece of string

+

quux: core

diff --git a/test/ssr/component-data-dynamic/data.json b/test/ssr/component-data-dynamic/data.json new file mode 100644 index 0000000000..89604b3e8b --- /dev/null +++ b/test/ssr/component-data-dynamic/data.json @@ -0,0 +1,6 @@ +{ + "bar": "lol", + "x": 2, + "compound": "piece of", + "go": { "deeper": "core" } +} diff --git a/test/ssr/component-data-dynamic/main.html b/test/ssr/component-data-dynamic/main.html new file mode 100644 index 0000000000..12d5f3208b --- /dev/null +++ b/test/ssr/component-data-dynamic/main.html @@ -0,0 +1,11 @@ +
+ +
+ + diff --git a/test/ssr/component-data-empty/Widget.html b/test/ssr/component-data-empty/Widget.html new file mode 100644 index 0000000000..89d0010a35 --- /dev/null +++ b/test/ssr/component-data-empty/Widget.html @@ -0,0 +1 @@ +

foo: '{{foo}}'

diff --git a/test/ssr/component-data-empty/_actual.html b/test/ssr/component-data-empty/_actual.html new file mode 100644 index 0000000000..dab5ab5387 --- /dev/null +++ b/test/ssr/component-data-empty/_actual.html @@ -0,0 +1 @@ +

foo: ''

\ No newline at end of file diff --git a/test/ssr/component-data-empty/_expected.html b/test/ssr/component-data-empty/_expected.html new file mode 100644 index 0000000000..ecaf8e5897 --- /dev/null +++ b/test/ssr/component-data-empty/_expected.html @@ -0,0 +1 @@ +

foo: ''

diff --git a/test/ssr/component-data-empty/main.html b/test/ssr/component-data-empty/main.html new file mode 100644 index 0000000000..8b797c8a60 --- /dev/null +++ b/test/ssr/component-data-empty/main.html @@ -0,0 +1,11 @@ +
+ +
+ + diff --git a/test/ssr/component-data-static/Widget.html b/test/ssr/component-data-static/Widget.html new file mode 100644 index 0000000000..573b6ffcc3 --- /dev/null +++ b/test/ssr/component-data-static/Widget.html @@ -0,0 +1,2 @@ +

foo: {{foo}}

+

baz: {{baz}} ({{typeof baz}})

diff --git a/test/ssr/component-data-static/_actual.html b/test/ssr/component-data-static/_actual.html new file mode 100644 index 0000000000..9502567ec5 --- /dev/null +++ b/test/ssr/component-data-static/_actual.html @@ -0,0 +1,2 @@ +

foo: bar

+

baz: 42 (number)

\ No newline at end of file diff --git a/test/ssr/component-data-static/_expected.html b/test/ssr/component-data-static/_expected.html new file mode 100644 index 0000000000..7e3d0496bd --- /dev/null +++ b/test/ssr/component-data-static/_expected.html @@ -0,0 +1,2 @@ +

foo: bar

+

baz: 42 (number)

diff --git a/test/ssr/component-data-static/main.html b/test/ssr/component-data-static/main.html new file mode 100644 index 0000000000..0df72c1465 --- /dev/null +++ b/test/ssr/component-data-static/main.html @@ -0,0 +1,11 @@ +
+ +
+ + diff --git a/test/ssr/component-yield/Widget.html b/test/ssr/component-yield/Widget.html new file mode 100644 index 0000000000..c1ffda500d --- /dev/null +++ b/test/ssr/component-yield/Widget.html @@ -0,0 +1,11 @@ +

{{yield}}

+ + diff --git a/test/ssr/component-yield/_actual.html b/test/ssr/component-yield/_actual.html new file mode 100644 index 0000000000..3c0acf1a81 --- /dev/null +++ b/test/ssr/component-yield/_actual.html @@ -0,0 +1 @@ +

Hello

\ No newline at end of file diff --git a/test/ssr/component-yield/_expected.html b/test/ssr/component-yield/_expected.html new file mode 100644 index 0000000000..fb13e0ab30 --- /dev/null +++ b/test/ssr/component-yield/_expected.html @@ -0,0 +1 @@ +

Hello

diff --git a/test/ssr/component-yield/main.html b/test/ssr/component-yield/main.html new file mode 100644 index 0000000000..cb1d683e78 --- /dev/null +++ b/test/ssr/component-yield/main.html @@ -0,0 +1,17 @@ +
+ {{data}} +
+ + diff --git a/test/ssr/component/Widget.html b/test/ssr/component/Widget.html new file mode 100644 index 0000000000..460a2a1c01 --- /dev/null +++ b/test/ssr/component/Widget.html @@ -0,0 +1 @@ +

i am a widget

diff --git a/test/ssr/component/_actual.html b/test/ssr/component/_actual.html new file mode 100644 index 0000000000..715d1a85c3 --- /dev/null +++ b/test/ssr/component/_actual.html @@ -0,0 +1 @@ +

i am a widget

\ No newline at end of file diff --git a/test/ssr/component/_expected.html b/test/ssr/component/_expected.html new file mode 100644 index 0000000000..3551c5971e --- /dev/null +++ b/test/ssr/component/_expected.html @@ -0,0 +1 @@ +

i am a widget

diff --git a/test/ssr/component/main.html b/test/ssr/component/main.html new file mode 100644 index 0000000000..5b119b5527 --- /dev/null +++ b/test/ssr/component/main.html @@ -0,0 +1,11 @@ +
+ +
+ + diff --git a/test/ssr/computed/_actual.html b/test/ssr/computed/_actual.html new file mode 100644 index 0000000000..f5a05c2882 --- /dev/null +++ b/test/ssr/computed/_actual.html @@ -0,0 +1,2 @@ +

1 + 2 = 3

+

3 * 3 = 9

\ No newline at end of file diff --git a/test/ssr/computed/_expected.html b/test/ssr/computed/_expected.html new file mode 100644 index 0000000000..0219d548a6 --- /dev/null +++ b/test/ssr/computed/_expected.html @@ -0,0 +1,2 @@ +

1 + 2 = 3

+

3 * 3 = 9

diff --git a/test/ssr/computed/data.json b/test/ssr/computed/data.json new file mode 100644 index 0000000000..27d5db50b5 --- /dev/null +++ b/test/ssr/computed/data.json @@ -0,0 +1,4 @@ +{ + "a": 1, + "b": 2 +} diff --git a/test/ssr/computed/main.html b/test/ssr/computed/main.html new file mode 100644 index 0000000000..6f92236436 --- /dev/null +++ b/test/ssr/computed/main.html @@ -0,0 +1,11 @@ +

{{a}} + {{b}} = {{c}}

+

{{c}} * {{c}} = {{cSquared}}

+ + diff --git a/test/ssr/default-data-override/_actual.html b/test/ssr/default-data-override/_actual.html new file mode 100644 index 0000000000..cfe6edcec5 --- /dev/null +++ b/test/ssr/default-data-override/_actual.html @@ -0,0 +1 @@ +

2

\ No newline at end of file diff --git a/test/ssr/default-data-override/_expected.html b/test/ssr/default-data-override/_expected.html new file mode 100644 index 0000000000..d1b089dc53 --- /dev/null +++ b/test/ssr/default-data-override/_expected.html @@ -0,0 +1 @@ +

2

diff --git a/test/ssr/default-data-override/data.json b/test/ssr/default-data-override/data.json new file mode 100644 index 0000000000..7625ba3b3c --- /dev/null +++ b/test/ssr/default-data-override/data.json @@ -0,0 +1,3 @@ +{ + "foo": 2 +} diff --git a/test/ssr/default-data-override/main.html b/test/ssr/default-data-override/main.html new file mode 100644 index 0000000000..3605487855 --- /dev/null +++ b/test/ssr/default-data-override/main.html @@ -0,0 +1,11 @@ +

{{foo}}

+ + diff --git a/test/ssr/default-data/_actual.html b/test/ssr/default-data/_actual.html new file mode 100644 index 0000000000..40001b6811 --- /dev/null +++ b/test/ssr/default-data/_actual.html @@ -0,0 +1 @@ +

1

\ No newline at end of file diff --git a/test/ssr/default-data/_expected.html b/test/ssr/default-data/_expected.html new file mode 100644 index 0000000000..c460ecf3a5 --- /dev/null +++ b/test/ssr/default-data/_expected.html @@ -0,0 +1 @@ +

1

diff --git a/test/ssr/default-data/main.html b/test/ssr/default-data/main.html new file mode 100644 index 0000000000..3605487855 --- /dev/null +++ b/test/ssr/default-data/main.html @@ -0,0 +1,11 @@ +

{{foo}}

+ + diff --git a/test/ssr/dynamic-text/_actual.html b/test/ssr/dynamic-text/_actual.html new file mode 100644 index 0000000000..85c8829392 --- /dev/null +++ b/test/ssr/dynamic-text/_actual.html @@ -0,0 +1 @@ +it works \ No newline at end of file diff --git a/test/ssr/dynamic-text/_expected.html b/test/ssr/dynamic-text/_expected.html new file mode 100644 index 0000000000..7658ad2c24 --- /dev/null +++ b/test/ssr/dynamic-text/_expected.html @@ -0,0 +1 @@ +it works diff --git a/test/ssr/dynamic-text/data.json b/test/ssr/dynamic-text/data.json new file mode 100644 index 0000000000..0f008a185b --- /dev/null +++ b/test/ssr/dynamic-text/data.json @@ -0,0 +1,3 @@ +{ + "foo": "it works" +} diff --git a/test/ssr/dynamic-text/main.html b/test/ssr/dynamic-text/main.html new file mode 100644 index 0000000000..054e96cb81 --- /dev/null +++ b/test/ssr/dynamic-text/main.html @@ -0,0 +1 @@ +{{foo}} diff --git a/test/ssr/each-block/_actual.html b/test/ssr/each-block/_actual.html new file mode 100644 index 0000000000..9f0c3c2b55 --- /dev/null +++ b/test/ssr/each-block/_actual.html @@ -0,0 +1 @@ +

1: alligator

2: beetle

3: cuckoo

\ No newline at end of file diff --git a/test/ssr/each-block/_expected.html b/test/ssr/each-block/_expected.html new file mode 100644 index 0000000000..86df2b82da --- /dev/null +++ b/test/ssr/each-block/_expected.html @@ -0,0 +1 @@ +

1: alligator

2: beetle

3: cuckoo

diff --git a/test/ssr/each-block/data.json b/test/ssr/each-block/data.json new file mode 100644 index 0000000000..febcba093c --- /dev/null +++ b/test/ssr/each-block/data.json @@ -0,0 +1,7 @@ +{ + "animals": [ + "alligator", + "beetle", + "cuckoo" + ] +} diff --git a/test/ssr/each-block/main.html b/test/ssr/each-block/main.html new file mode 100644 index 0000000000..dfe0195d2a --- /dev/null +++ b/test/ssr/each-block/main.html @@ -0,0 +1,3 @@ +{{#each animals as animal, i}} +

{{i + 1}}: {{animal}}

+{{/each}} diff --git a/test/ssr/helpers/_actual.html b/test/ssr/helpers/_actual.html new file mode 100644 index 0000000000..4b5c34ffb9 --- /dev/null +++ b/test/ssr/helpers/_actual.html @@ -0,0 +1 @@ +

3

\ No newline at end of file diff --git a/test/ssr/helpers/_expected.html b/test/ssr/helpers/_expected.html new file mode 100644 index 0000000000..ca54385e2b --- /dev/null +++ b/test/ssr/helpers/_expected.html @@ -0,0 +1 @@ +

3

diff --git a/test/ssr/helpers/main.html b/test/ssr/helpers/main.html new file mode 100644 index 0000000000..de61efe8a0 --- /dev/null +++ b/test/ssr/helpers/main.html @@ -0,0 +1,15 @@ +

{{thrice(foo)}}

+ + diff --git a/test/ssr/if-block-false/_actual.html b/test/ssr/if-block-false/_actual.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/ssr/if-block-false/_expected.html b/test/ssr/if-block-false/_expected.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/ssr/if-block-false/data.json b/test/ssr/if-block-false/data.json new file mode 100644 index 0000000000..5b42b1ce4f --- /dev/null +++ b/test/ssr/if-block-false/data.json @@ -0,0 +1,3 @@ +{ + "foo": false +} diff --git a/test/ssr/if-block-false/main.html b/test/ssr/if-block-false/main.html new file mode 100644 index 0000000000..2824b7e504 --- /dev/null +++ b/test/ssr/if-block-false/main.html @@ -0,0 +1,3 @@ +{{#if foo}} +

foo is true

+{{/if}} diff --git a/test/ssr/if-block-true/_actual.html b/test/ssr/if-block-true/_actual.html new file mode 100644 index 0000000000..df979b8d53 --- /dev/null +++ b/test/ssr/if-block-true/_actual.html @@ -0,0 +1 @@ +

foo is true

\ No newline at end of file diff --git a/test/ssr/if-block-true/_expected.html b/test/ssr/if-block-true/_expected.html new file mode 100644 index 0000000000..b6f3d8a330 --- /dev/null +++ b/test/ssr/if-block-true/_expected.html @@ -0,0 +1 @@ +

foo is true

diff --git a/test/ssr/if-block-true/data.json b/test/ssr/if-block-true/data.json new file mode 100644 index 0000000000..79cc1f44f6 --- /dev/null +++ b/test/ssr/if-block-true/data.json @@ -0,0 +1,3 @@ +{ + "foo": true +} diff --git a/test/ssr/if-block-true/main.html b/test/ssr/if-block-true/main.html new file mode 100644 index 0000000000..2824b7e504 --- /dev/null +++ b/test/ssr/if-block-true/main.html @@ -0,0 +1,3 @@ +{{#if foo}} +

foo is true

+{{/if}} diff --git a/test/ssr/static-div/_actual.html b/test/ssr/static-div/_actual.html new file mode 100644 index 0000000000..78e7012b82 --- /dev/null +++ b/test/ssr/static-div/_actual.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/ssr/static-div/_expected.html b/test/ssr/static-div/_expected.html new file mode 100644 index 0000000000..7c89b545c5 --- /dev/null +++ b/test/ssr/static-div/_expected.html @@ -0,0 +1 @@ +
diff --git a/test/ssr/static-div/main.html b/test/ssr/static-div/main.html new file mode 100644 index 0000000000..7c89b545c5 --- /dev/null +++ b/test/ssr/static-div/main.html @@ -0,0 +1 @@ +
diff --git a/test/ssr/static-text/_actual.html b/test/ssr/static-text/_actual.html new file mode 100644 index 0000000000..b649a9bf89 --- /dev/null +++ b/test/ssr/static-text/_actual.html @@ -0,0 +1 @@ +some text \ No newline at end of file diff --git a/test/ssr/static-text/_expected.html b/test/ssr/static-text/_expected.html new file mode 100644 index 0000000000..7b57bd29ea --- /dev/null +++ b/test/ssr/static-text/_expected.html @@ -0,0 +1 @@ +some text diff --git a/test/ssr/static-text/main.html b/test/ssr/static-text/main.html new file mode 100644 index 0000000000..7b57bd29ea --- /dev/null +++ b/test/ssr/static-text/main.html @@ -0,0 +1 @@ +some text diff --git a/test/test.js b/test/test.js index f9d01848d0..0eff94bd02 100644 --- a/test/test.js +++ b/test/test.js @@ -62,6 +62,15 @@ function addLineNumbers ( code ) { }).join( '\n' ); } +function tryToLoadJson ( file ) { + try { + return JSON.parse( fs.readFileSync( file ) ); + } catch ( err ) { + if ( err.code !== 'ENOENT' ) throw err; + return null; + } +} + describe( 'svelte', () => { before( () => { function cleanChildren ( node ) { @@ -154,15 +163,6 @@ describe( 'svelte', () => { }); describe( 'validate', () => { - function tryToLoadJson ( file ) { - try { - return JSON.parse( fs.readFileSync( file ) ); - } catch ( err ) { - if ( err.code !== 'ENOENT' ) throw err; - return null; - } - } - fs.readdirSync( 'test/validator' ).forEach( dir => { if ( dir[0] === '.' ) return; @@ -505,4 +505,29 @@ describe( 'svelte', () => { }); }); }); + + describe( 'ssr', () => { + before( () => { + require( '../ssr/register' ); + }); + + fs.readdirSync( 'test/ssr' ).forEach( dir => { + if ( dir[0] === '.' ) return; + + const solo = exists( `test/ssr/${dir}/solo` ); + + ( solo ? it.only : it )( dir, () => { + const component = require( `./ssr/${dir}/main.html` ); + + const expected = fs.readFileSync( `test/ssr/${dir}/_expected.html`, 'utf-8' ); + + const data = tryToLoadJson( `test/ssr/${dir}/data.json` ); + const actual = component.render( data ); + + fs.writeFileSync( `test/ssr/${dir}/_actual.html`, actual ); + + assert.htmlEqual( actual, expected ); + }); + }); + }); });