@@ -5,25 +5,28 @@ const jsdom = require('jsdom');
5
5
const expect = unexpected . clone ( ) . installPlugin ( unexpectedDom ) ;
6
6
expect . output . installPlugin ( require ( 'magicpen-prism' ) ) ;
7
7
8
- expect . addAssertion ( 'to inspect as [itself]' , function ( expect , subject , value ) {
9
- const originalSubject = subject ;
10
- if ( typeof subject === 'string' ) {
11
- subject = new jsdom . JSDOM (
12
- `<!DOCTYPE html><html><head></head><body>${ subject } </body></html>`
13
- ) . window . document . body . firstChild ;
14
- }
15
- if ( this . flags . itself ) {
16
- if ( typeof originalSubject === 'string' ) {
17
- expect ( expect . inspect ( subject ) . toString ( ) , 'to equal' , originalSubject ) ;
8
+ expect . addAssertion (
9
+ '<string|DOMNode> to inspect as [itself] <string?>' ,
10
+ function ( expect , subject , value ) {
11
+ const originalSubject = subject ;
12
+ if ( typeof subject === 'string' ) {
13
+ subject = new jsdom . JSDOM (
14
+ `<!DOCTYPE html><html><head></head><body>${ subject } </body></html>`
15
+ ) . window . document . body . firstChild ;
16
+ }
17
+ if ( this . flags . itself ) {
18
+ if ( typeof originalSubject === 'string' ) {
19
+ expect ( expect . inspect ( subject ) . toString ( ) , 'to equal' , originalSubject ) ;
20
+ } else {
21
+ throw new Error (
22
+ 'subject must be given as a string when expected to inspect as itself'
23
+ ) ;
24
+ }
18
25
} else {
19
- throw new Error (
20
- 'subject must be given as a string when expected to inspect as itself'
21
- ) ;
26
+ expect ( expect . inspect ( subject ) . toString ( ) , 'to equal' , value ) ;
22
27
}
23
- } else {
24
- expect ( expect . inspect ( subject ) . toString ( ) , 'to equal' , value ) ;
25
28
}
26
- } ) ;
29
+ ) ;
27
30
28
31
describe ( 'jsdom bug compatibility' , ( ) => {
29
32
it ( 'should work without issue #1107 fixed' , ( ) => {
0 commit comments