Skip to content

Commit

Permalink
Keep Jest env to node but add createElement for portal test
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jan 5, 2022
1 parent 07fbab1 commit 0991197
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/__tests__/visitor.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { JSDOM } from 'jsdom'

import React, {
Component,
Fragment,
Expand Down Expand Up @@ -27,9 +29,8 @@ import {

import { visitElement } from '../visitor'

const {
ReactCurrentDispatcher
} = (React: any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
const { ReactCurrentDispatcher } = (React: any)
.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

let prevDispatcher = null

Expand Down Expand Up @@ -173,6 +174,7 @@ describe('visitElement', () => {
})

it('returns nothing for portal components', () => {
const document = new JSDOM().window.document
const portal = createPortal(<Noop />, document.createElement('div'))
const children = visitElement(portal, [], () => {})
expect(children.length).toBe(0)
Expand Down

0 comments on commit 0991197

Please sign in to comment.