jest-fixed-jsdom
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -11,6 +11,2 @@ const JSDOMEnvironment = require('jest-environment-jsdom').default | ||
this.global.EventTarget = EventTarget | ||
this.global.Event = Event | ||
this.global.MessageEvent = MessageEvent | ||
this.global.Blob = Blob | ||
@@ -17,0 +13,0 @@ this.global.Headers = Headers |
@@ -91,62 +91,1 @@ test('exposes "Blob"', async () => { | ||
test('exposes "EventTarget"', () => { | ||
expect(globalThis).toHaveProperty('EventTarget') | ||
expect(() => new EventTarget()).not.toThrow() | ||
const target = new EventTarget() | ||
const symbols = Object.getOwnPropertySymbols(target).map( | ||
(symbol) => symbol.description, | ||
) | ||
// EventTarget must not be implemented by JSDOM. | ||
expect(symbols).not.toContain('impl') | ||
// In Node.js, EventTarget keeps events behind the kEvents symbol. | ||
expect(symbols).toContain('kEvents') | ||
}) | ||
test('exposes "Event"', () => { | ||
expect(globalThis).toHaveProperty('Event') | ||
expect(() => new Event('click')).not.toThrow() | ||
const event = new Event('click') | ||
const symbols = Object.getOwnPropertySymbols(event).map( | ||
(symbol) => symbol.description, | ||
) | ||
// The "impl" symbol is added by JSDOM. | ||
expect(symbols).not.toContain('impl') | ||
// Node.js expects events to have the "type" symbol. | ||
expect(symbols).toContain('type') | ||
/** | ||
* Perform a basic "isEvent()" check that Node.js has. | ||
* @see https://github.com/nodejs/node/blob/3a456c6db802b5b25594d3a9d235d4989e9f7829/lib/internal/event_target.js#L96 | ||
*/ | ||
expect(event[symbols.find((description) => description === 'type')]).toBe( | ||
'click', | ||
) | ||
}) | ||
test('exposes "MessageEvent"', () => { | ||
expect(globalThis).toHaveProperty('MessageEvent') | ||
expect(() => new MessageEvent('click')).not.toThrow() | ||
const event = new MessageEvent('message') | ||
const symbols = Object.getOwnPropertySymbols(event).map( | ||
(symbol) => symbol.description, | ||
) | ||
// The "impl" symbol is added by JSDOM. | ||
expect(symbols).not.toContain('impl') | ||
// Node.js expects events to have the "type" symbol. | ||
expect(symbols).toContain('type') | ||
/** | ||
* Perform a basic "isEvent()" check that Node.js has. | ||
* @see https://github.com/nodejs/node/blob/3a456c6db802b5b25594d3a9d235d4989e9f7829/lib/internal/event_target.js#L96 | ||
*/ | ||
expect(event[symbols.find((description) => description === 'type')]).toBe( | ||
'message', | ||
) | ||
}) |
{ | ||
"name": "jest-fixed-jsdom", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A superset of the JSDOM environment for Jest that respects Node.js globals.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8015
104