1
- import { fireEvent as dtlFireEvent , getQueriesForElement , prettyDOM } from '@testing-library/dom'
1
+ import {
2
+ fireEvent as dtlFireEvent ,
3
+ getQueriesForElement ,
4
+ prettyDOM ,
5
+ } from '@testing-library/dom'
2
6
import { tick } from 'svelte'
3
7
4
8
const containerCache = new Map ( )
5
9
const componentCache = new Set ( )
6
10
7
11
const svelteComponentOptions = [
12
+ 'accessors' ,
8
13
'anchor' ,
9
14
'props' ,
10
15
'hydrate' ,
11
16
'intro' ,
12
- 'context'
17
+ 'context' ,
13
18
]
14
19
15
20
const render = (
@@ -51,13 +56,15 @@ const render = (
51
56
52
57
let component = new ComponentConstructor ( {
53
58
target,
54
- ...checkProps ( options )
59
+ ...checkProps ( options ) ,
55
60
} )
56
61
57
62
containerCache . set ( container , { target, component } )
58
63
componentCache . add ( component )
59
64
60
- component . $$ . on_destroy . push ( ( ) => { componentCache . delete ( component ) } )
65
+ component . $$ . on_destroy . push ( ( ) => {
66
+ componentCache . delete ( component )
67
+ } )
61
68
62
69
return {
63
70
container,
@@ -69,18 +76,20 @@ const render = (
69
76
// eslint-disable-next-line no-new
70
77
component = new ComponentConstructor ( {
71
78
target,
72
- ...checkProps ( options )
79
+ ...checkProps ( options ) ,
73
80
} )
74
81
75
82
containerCache . set ( container , { target, component } )
76
83
componentCache . add ( component )
77
84
78
- component . $$ . on_destroy . push ( ( ) => { componentCache . delete ( component ) } )
85
+ component . $$ . on_destroy . push ( ( ) => {
86
+ componentCache . delete ( component )
87
+ } )
79
88
} ,
80
89
unmount : ( ) => {
81
90
if ( componentCache . has ( component ) ) component . $destroy ( )
82
91
} ,
83
- ...getQueriesForElement ( container , queries )
92
+ ...getQueriesForElement ( container , queries ) ,
84
93
}
85
94
}
86
95
@@ -89,7 +98,9 @@ const cleanupAtContainer = (container) => {
89
98
90
99
if ( componentCache . has ( component ) ) component . $destroy ( )
91
100
92
- if ( target . parentNode === document . body ) { document . body . removeChild ( target ) }
101
+ if ( target . parentNode === document . body ) {
102
+ document . body . removeChild ( target )
103
+ }
93
104
94
105
containerCache . delete ( container )
95
106
}
@@ -124,6 +135,4 @@ Object.keys(dtlFireEvent).forEach((key) => {
124
135
125
136
export * from '@testing-library/dom'
126
137
127
- export {
128
- render , cleanup , fireEvent , act
129
- }
138
+ export { render , cleanup , fireEvent , act }
0 commit comments