@@ -26,14 +26,16 @@ test('prettyDOM supports truncating the output length', () => {
26
26
} )
27
27
28
28
test ( 'prettyDOM defaults to document.body' , ( ) => {
29
+ const defaultInlineSnapshot = `
30
+ "<body>
31
+ <div>
32
+ Hello World!
33
+ </div>
34
+ </body>"
35
+ `
29
36
renderIntoDocument ( '<div>Hello World!</div>' )
30
- expect ( prettyDOM ( ) ) . toMatchInlineSnapshot ( `
31
- "<body>
32
- <div>
33
- Hello World!
34
- </div>
35
- </body>"
36
- ` )
37
+ expect ( prettyDOM ( ) ) . toMatchInlineSnapshot ( defaultInlineSnapshot )
38
+ expect ( prettyDOM ( null ) ) . toMatchInlineSnapshot ( defaultInlineSnapshot )
37
39
} )
38
40
39
41
test ( 'prettyDOM supports receiving the document element' , ( ) => {
@@ -58,4 +60,22 @@ test('logDOM logs prettyDOM to the console', () => {
58
60
` )
59
61
} )
60
62
63
+ describe ( 'prettyDOM fails with first parameter without outerHTML field' , ( ) => {
64
+ test ( 'with array' , ( ) => {
65
+ expect ( ( ) => prettyDOM ( [ 'outerHTML' ] ) ) . toThrowErrorMatchingInlineSnapshot (
66
+ `"Expected an element or document but got Array"` ,
67
+ )
68
+ } )
69
+ test ( 'with number' , ( ) => {
70
+ expect ( ( ) => prettyDOM ( 1 ) ) . toThrowErrorMatchingInlineSnapshot (
71
+ `"Expected an element or document but got number"` ,
72
+ )
73
+ } )
74
+ test ( 'with object' , ( ) => {
75
+ expect ( ( ) => prettyDOM ( { } ) ) . toThrowErrorMatchingInlineSnapshot (
76
+ `"Expected an element or document but got Object"` ,
77
+ )
78
+ } )
79
+ } )
80
+
61
81
/* eslint no-console:0 */
0 commit comments