File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 1+ /* eslint-disable @typescript-eslint/no-explicit-any */
2+
13import * as React from "react" ;
24
5+ function isReactElement ( val : any ) : boolean {
6+ return Boolean ( val . $$typeof && val . $$typeof === Symbol . for ( "react.element" ) ) ;
7+ }
8+
9+ function isScriptElement ( val : any ) : boolean {
10+ return Boolean ( val . type && val . type === "script" ) ;
11+ }
12+
13+ function hasValidProps ( val : any ) : boolean {
14+ return Boolean (
15+ val . props &&
16+ val . props . dangerouslySetInnerHTML &&
17+ val . props . type &&
18+ val . props . type === "application/ld+json"
19+ ) ;
20+ }
21+
322const JSONLDSerializer : jest . SnapshotSerializerPlugin = {
423 test ( val ) {
524 return Boolean (
6- val &&
7- val . $$typeof === Symbol . for ( "react.element" ) &&
8- val . type === "script" &&
9- val . props . dangerouslySetInnerHTML &&
10- val . props . type &&
11- val . props . type === "application/ld+json"
25+ val && isReactElement ( val ) && isScriptElement ( val ) && hasValidProps ( val )
1226 ) ;
1327 } ,
1428
You can’t perform that action at this time.
0 commit comments