From afd45bd99d65fe43cc17d607aa90ab6344da52b5 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 12 May 2021 14:47:18 +0200 Subject: [PATCH] Reorganize frontend tests and add more $locals tests --- assets/views/layouts/svelte_layout.html | 6 ++- test/assets/views/AllTests.svelte | 34 ++++++++++++++ test/assets/views/LocalsTest.svelte | 25 ++++++++++ test/assets/views/Test.svelte | 42 +++++++++++++++++ test/assets/views/home_dep.svelte | 26 ----------- test/assets/views/home_test.svelte | 61 ------------------------- 6 files changed, 105 insertions(+), 89 deletions(-) create mode 100644 test/assets/views/AllTests.svelte create mode 100644 test/assets/views/LocalsTest.svelte create mode 100644 test/assets/views/Test.svelte delete mode 100644 test/assets/views/home_dep.svelte delete mode 100644 test/assets/views/home_test.svelte diff --git a/assets/views/layouts/svelte_layout.html b/assets/views/layouts/svelte_layout.html index caf13b9..599f6c6 100644 --- a/assets/views/layouts/svelte_layout.html +++ b/assets/views/layouts/svelte_layout.html @@ -11,9 +11,11 @@ const locals = %locals%; localStore.set((key, args) => { - return locals[args ? + const localKey = args ? `'${key}', \`${args}\`` - : `'${key}'`]; + : `'${key}'`; + // console.debug(localKey + '=' + locals[localKey]) + return locals[localKey]; }); new View({ diff --git a/test/assets/views/AllTests.svelte b/test/assets/views/AllTests.svelte new file mode 100644 index 0000000..caafcaf --- /dev/null +++ b/test/assets/views/AllTests.svelte @@ -0,0 +1,34 @@ + + + + +
{$locals.isPreRender ? 'SSR' : 'CSR'}
+ + + + + + + + + + + + + +
NameExpected valueActual value
diff --git a/test/assets/views/LocalsTest.svelte b/test/assets/views/LocalsTest.svelte new file mode 100644 index 0000000..37a8003 --- /dev/null +++ b/test/assets/views/LocalsTest.svelte @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/assets/views/Test.svelte b/test/assets/views/Test.svelte new file mode 100644 index 0000000..aaa1b8f --- /dev/null +++ b/test/assets/views/Test.svelte @@ -0,0 +1,42 @@ + + + + + + {name} + {#if not}!{/if}{expectedValue} + {actualValue} + diff --git a/test/assets/views/home_dep.svelte b/test/assets/views/home_dep.svelte deleted file mode 100644 index fc506de..0000000 --- a/test/assets/views/home_dep.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -

Simple dep test

-

\$locals.

-

\$locals.

- -

$locals: {$locals}

-

\$locals.route: {$locals.route}
{$locals.dump(typeof $locals.route)}

-

\$locals.dump: {$locals.dump('bonjour')}

-

\$locals.dump: {$locals.dump($locals.app)}

-

\$locals.dump: {$locals.dump(NaN)}

-

\$locals.route: {$locals.route('auth')}

-

\$locals.route: {$locals.route('home')}

diff --git a/test/assets/views/home_test.svelte b/test/assets/views/home_test.svelte deleted file mode 100644 index b54040a..0000000 --- a/test/assets/views/home_test.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - - - -

{mode}

- - - -

BONJOUR lol

-
-
- -

Hello {count}!

- - - -

Direct access: {$locals.direct}

- -{#if $locals.route('auth') === '/'} - We're home! -{:else} - We're somewhere else... {$locals.route('auth')} -{/if} - -

The route to auth is {$locals.route('auth')}

- -

\$locals.notcode

- -

{`{\\$locals.escaped}`}

- -
-

Blue!

-
- - - -

Dependency test: {depTest}