-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added workaround for unfixed jsdom bug jsdom/jsdom#1107
- Loading branch information
Showing
2 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*global describe, it*/ | ||
var unexpected = require('unexpected'), | ||
unexpectedDom = require('../lib/index'), | ||
jsdom = require('jsdom'); | ||
|
||
var expect = unexpected.clone().installPlugin(unexpectedDom); | ||
expect.output.installPlugin(require('magicpen-prism')); | ||
|
||
expect.addAssertion('to inspect as [itself]', function (expect, subject, value) { | ||
var originalSubject = subject; | ||
if (typeof subject === 'string') { | ||
subject = jsdom.jsdom('<!DOCTYPE html><html><head></head><body>' + subject + '</body></html>').body.firstChild; | ||
} | ||
if (this.flags.itself) { | ||
if (typeof originalSubject === 'string') { | ||
expect(expect.inspect(subject).toString(), 'to equal', originalSubject); | ||
} else { | ||
throw new Error('subject must be given as a string when expected to inspect as itself'); | ||
} | ||
} else { | ||
expect(expect.inspect(subject).toString(), 'to equal', value); | ||
} | ||
}); | ||
|
||
describe('jsdom bug compatibility', function () { | ||
it('should work without issue #1107 fixed', function() { | ||
// https://github.com/tmpvar/jsdom/issues/1107 | ||
expect('<select><option value="foo">bar</option></select>', 'to inspect as itself'); | ||
expect('<form><p>foo</p></form>', 'to inspect as itself'); | ||
}); | ||
}); |