|
1 |
| -import { assert, test } from 'vitest'; |
| 1 | +import { strFromU8 } from 'fflate'; |
| 2 | +import { assert, expect, test } from 'vitest'; |
2 | 3 | import {
|
3 |
| - filesToStr, |
4 |
| - strToFiles, |
5 |
| - createPlaygroundShareUrl, |
6 | 4 | compressFiles,
|
7 |
| - parseCompressedFiles, |
| 5 | + createPlaygroundShareUrl, |
8 | 6 | dictionary,
|
| 7 | + filesToStr, |
| 8 | + parseCompressedFiles, |
| 9 | + parsePlaygroundShareUrl, |
| 10 | + strToFiles, |
9 | 11 | } from './repl-share-url';
|
10 |
| -import { strFromU8 } from 'fflate'; |
11 | 12 |
|
12 | 13 | const data = {
|
13 | 14 | version: '1.2.3',
|
@@ -64,8 +65,86 @@ test('createPlaygroundShareUrl 2', () => {
|
64 | 65 | });
|
65 | 66 |
|
66 | 67 | test('dictionary is unchanged', () => {
|
67 |
| - assert.equal( |
68 |
| - strFromU8(dictionary), |
69 |
| - "0||1448|<div> </div> </button> props: class return ( story component$( store string state export const span type href={ page strong count useSignal< useStore< qwik import { } from searchInput console.log( searchResults builder useTask$( stories style={ news export default data </article> track onClick$= new nav map link debounced controller user useStyles$( useStylesScoped$( url title timeoutId time_ago second response Date.now() minute main item interface hour disabled aria any State update transform the target suggestion setTimeout selectedValue rotate render people number list label https:// header deg debouncedGetPeople debounce component comments_count comments clock background await new Promise args SuggestionsListComponent IStory IState IComment GrandChild Clock Child AutoComplete 360 yellow with view useVisibleTask$( true tmrId timer then swapi styles signal section search results resolve rel prev points parsedResponse null noreferrer name more length json job items isServer index github getPeople function fetch example domain dev delay css container com click clearTimeout async api _blank Star Wars API This The StoryPreview Stories ReturnType Qwik App Page Nav HackerNewsCSS AbortController server$( routeAction$( routeLoader$( useContent( useDocumentHead( useLocation( useNavigate( validator$( zod$( noSerialize( </Slot> useComputed$( useOnDocument( useOnWindow( useResource$( useContext( useContextProvider( createContextId<|8|/app.tsx|114|import { component$ } from '@builder.io/qwik';\n\nexport default component$(() => {\n return <p>Hello Qwik</p>;\n});\n|17|/entry.server.tsx|201|import { renderToString, type RenderOptions } from '@builder.io/qwik/server';\nimport { Root } from './root';\n\nexport default function (opts: RenderOptions) {\n return renderToString(<Root />, opts);\n}\n|9|/root.tsx|192|import App from './app';\n\nexport const Root = () => {\n return (\n <>\n <head>\n <title>Hello Qwik</title>\n </head>\n <body>\n <App />\n </body>\n </>\n );\n};\n" |
| 68 | + const dictionaryAsString = strFromU8(dictionary); |
| 69 | + // !!! THIS DICTIONARY MUST NEVER CHANGE - ONLY ALLOW PREPENDING !!! |
| 70 | + expect(dictionaryAsString).toMatchInlineSnapshot(` |
| 71 | + "8|/app.tsx|149|import { component$ } from '@qwik.dev/core'; |
| 72 | +
|
| 73 | + export default component$(() => { |
| 74 | + return ( |
| 75 | + <div> |
| 76 | + <h1>Hello from Qwik!</h1> |
| 77 | + </div> |
| 78 | + ); |
| 79 | + |0||1448|<div> </div> </button> props: class return ( story component$( store string state export const span type href={ page strong count useSignal< useStore< qwik import { } from searchInput console.log( searchResults builder useTask$( stories style={ news export default data </article> track onClick$= new nav map link debounced controller user useStyles$( useStylesScoped$( url title timeoutId time_ago second response Date.now() minute main item interface hour disabled aria any State update transform the target suggestion setTimeout selectedValue rotate render people number list label https:// header deg debouncedGetPeople debounce component comments_count comments clock background await new Promise args SuggestionsListComponent IStory IState IComment GrandChild Clock Child AutoComplete 360 yellow with view useVisibleTask$( true tmrId timer then swapi styles signal section search results resolve rel prev points parsedResponse null noreferrer name more length json job items isServer index github getPeople function fetch example domain dev delay css container com click clearTimeout async api _blank Star Wars API This The StoryPreview Stories ReturnType Qwik App Page Nav HackerNewsCSS AbortController server$( routeAction$( routeLoader$( useContent( useDocumentHead( useLocation( useNavigate( validator$( zod$( noSerialize( </Slot> useComputed$( useOnDocument( useOnWindow( useResource$( useContext( useContextProvider( createContextId<|8|/app.tsx|114|import { component$ } from '@builder.io/qwik'; |
| 80 | +
|
| 81 | + export default component$(() => { |
| 82 | + return <p>Hello Qwik</p>; |
| 83 | + }); |
| 84 | + |17|/entry.server.tsx|201|import { renderToString, type RenderOptions } from '@builder.io/qwik/server'; |
| 85 | + import { Root } from './root'; |
| 86 | +
|
| 87 | + export default function (opts: RenderOptions) { |
| 88 | + return renderToString(<Root />, opts); |
| 89 | + } |
| 90 | + |9|/root.tsx|192|import App from './app'; |
| 91 | +
|
| 92 | + export const Root = () => { |
| 93 | + return ( |
| 94 | + <> |
| 95 | + <head> |
| 96 | + <title>Hello Qwik</title> |
| 97 | + </head> |
| 98 | + <body> |
| 99 | + <App /> |
| 100 | + </body> |
| 101 | + </> |
| 102 | + ); |
| 103 | + }; |
| 104 | + " |
| 105 | + `); |
| 106 | +}); |
| 107 | + |
| 108 | +test('previous URLs still work', () => { |
| 109 | + expect(parsePlaygroundShareUrl('f=G000o4mG5EQDAA')).toHaveProperty( |
| 110 | + 'files', |
| 111 | + // DO NOT UPDATE THIS TEST - all these URLs must work forever |
| 112 | + expect.arrayContaining([ |
| 113 | + expect.objectContaining({ |
| 114 | + path: '/app.tsx', |
| 115 | + code: "import { component$ } from '@builder.io/qwik';\n\nexport default component$(() => {\n return <p>Hello Qwik</p>;\n});\n", |
| 116 | + }), |
| 117 | + ]) |
| 118 | + ); |
| 119 | + expect( |
| 120 | + parsePlaygroundShareUrl( |
| 121 | + 'f=Q0o0xgaW2BKNDrDkqNCB15QUpyFIgKTl51uBeGA%2BKO%2BBIwaW0W1A6SI%2FDWQzyKm1wKBDVwyU0lAqUNJRqE4GFc3AqLNSCnENDlGq1QTpAGJ43a5RDa6oa0FOgBsDbxkAXQIMCqAWMIktXqqBSvRgNoNMRg7C0XQ%2FJNM9AA' |
| 122 | + ) |
| 123 | + ).toHaveProperty( |
| 124 | + 'files', |
| 125 | + // DO NOT UPDATE THIS TEST - all these URLs must work forever |
| 126 | + expect.arrayContaining([ |
| 127 | + expect.objectContaining({ |
| 128 | + path: '/app.tsx', |
| 129 | + code: `import { component$, jsx, useTask$ } from '@builder.io/qwik'; |
| 130 | +
|
| 131 | +export default component$(() => { |
| 132 | + const foo:{ |
| 133 | + contents: ReturnType<typeof jsx> |
| 134 | + } = { |
| 135 | + contents: jsx("p", {children:"TEST"}) |
| 136 | + } |
| 137 | + useTask$(({track}) =>{ |
| 138 | + console.log(foo); |
| 139 | + }); |
| 140 | + return ( |
| 141 | + <> |
| 142 | + {foo.contents} |
| 143 | + </> |
| 144 | + ); |
| 145 | +}); |
| 146 | +`, |
| 147 | + }), |
| 148 | + ]) |
70 | 149 | );
|
71 | 150 | });
|
0 commit comments