File tree Expand file tree Collapse file tree 7 files changed +53
-57
lines changed Expand file tree Collapse file tree 7 files changed +53
-57
lines changed Original file line number Diff line number Diff line change 28
28
"tslib" : " ^2.3.1" ,
29
29
"typescript" : " ^4.5.4" ,
30
30
"vitest" : " ^0.0.138" ,
31
- "vite-plugin-svelte-inline-compile " : " ^0.0.1 "
31
+ "vite-plugin-svelte-inline-components " : " file://Users/miguelcamba/code/own/vite-plugin-svelte-inline-components "
32
32
},
33
33
"type" : " module" ,
34
34
"dependencies" : {
Original file line number Diff line number Diff line change 4
4
<div
5
5
data-testid =" definition-entry"
6
6
class =" {background === ' gray' ? ' bg-gray-50' : ' bg-white' } px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6" >
7
- <dt class =" text-sm font-medium text-gray-500" >
7
+ <dt class =" text-sm font-medium text-gray-500" data-testid = " dt " >
8
8
<slot name =" dt" />
9
9
</dt >
10
- <dd class =" mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2" >
10
+ <dd class =" mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2" data-testid = " dd " >
11
11
<slot name =" dd" ></slot >
12
12
</dd >
13
13
</div >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { cleanup , render } from '@testing-library/svelte'
2
+ import { svelte } from 'vite-plugin-svelte-inline-components' ;
3
+
4
+ describe ( 'DefinitionEntry.svelte' , ( ) => {
5
+ // TODO: @testing -library/svelte claims to add this automatically but it doesn't work without explicit afterEach
6
+ afterEach ( ( ) => cleanup ( ) )
7
+
8
+ it ( 'renders a link with the given href' , async ( ) => {
9
+ const { getByTestId } = render ( await svelte `
10
+ <script>import DefinitionEntry from '$lib/DefinitionEntry.svelte';</script>
11
+ <DefinitionEntry background="gray">
12
+ <svelte:fragment slot="dt">I'm the description term</svelte:fragment>
13
+ <svelte:fragment slot="dd">I'm the description definition</svelte:fragment>
14
+ </DefinitionEntry>
15
+ ` ) ;
16
+ expect ( getByTestId ( 'definition-entry' ) ) . to . have . class ( 'bg-gray-50' ) ;
17
+ expect ( getByTestId ( 'dt' ) ) . to . have . text ( "I'm the description term" ) ;
18
+ expect ( getByTestId ( 'dd' ) ) . to . have . text ( "I'm the description definition" ) ;
19
+ } ) ;
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { cleanup , render } from '@testing-library/svelte'
2
+ import { svelte } from 'vite-plugin-svelte-inline-components' ;
3
+
4
+ describe ( 'NavLink.svelte' , ( ) => {
5
+ // TODO: @testing -library/svelte claims to add this automatically but it doesn't work without explicit afterEach
6
+ afterEach ( ( ) => cleanup ( ) )
7
+
8
+ it ( 'renders a link with the given href' , async ( ) => {
9
+ const { getByTestId } = render ( await svelte `
10
+ <script>import NavLink from '$lib/NavLink.svelte';</script>
11
+ <NavLink href="/foo/bar">Link text</NavLink>
12
+ ` ) ;
13
+ expect ( getByTestId ( 'definition-entry' ) ) . to . have . class ( 'bg-gray-50' ) ;
14
+ expect ( getByTestId ( 'dt' ) ) . to . have . text ( "I'm the description term" ) ;
15
+ expect ( getByTestId ( 'dd' ) ) . to . have . text ( "I'm the description definition" ) ;
16
+ } ) ;
17
+ } ) ;
Original file line number Diff line number Diff line change @@ -2,16 +2,15 @@ import { defineConfig } from 'vite'
2
2
import { svelte } from '@sveltejs/vite-plugin-svelte'
3
3
import { sveltekitViteConfig } from './svelte.config.js'
4
4
import path from 'path' ;
5
- import svelteInlineCompile from 'vite-plugin-svelte-inline-compile ' ;
5
+ import svelteInlineComponents from 'vite-plugin-svelte-inline-components ' ;
6
6
7
7
export default defineConfig ( {
8
8
...sveltekitViteConfig ,
9
9
plugins : [
10
10
svelte ( {
11
11
hot : ! process . env . VITEST ,
12
- compilerOptions : { format : "cjs" }
13
12
} ) ,
14
- svelteInlineCompile ( ) ,
13
+ svelteInlineComponents ( ) ,
15
14
] ,
16
15
test : {
17
16
global : true ,
You can’t perform that action at this time.
0 commit comments