-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable disable port in test env
- Loading branch information
Showing
7 changed files
with
88 additions
and
6 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import Portal from './Portal'; | ||
import type { PortalProps } from './Portal'; | ||
import { inlineMock } from './mock'; | ||
|
||
export type { PortalProps }; | ||
export { inlineMock }; | ||
|
||
export default Portal; |
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,8 @@ | ||
export let inline = false; | ||
|
||
export function inlineMock(nextInline?: boolean) { | ||
if (typeof nextInline === 'boolean') { | ||
inline = nextInline; | ||
} | ||
return inline; | ||
} |
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,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test Env inlineMock 1`] = ` | ||
<div> | ||
Start | ||
<div | ||
class="bamboo" | ||
> | ||
Hello World | ||
</div> | ||
End | ||
</div> | ||
`; |
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 @@ | ||
import '@testing-library/jest-dom'; |
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,19 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Portal from '../src'; | ||
|
||
jest.mock('rc-util/lib/Dom/canUseDom', () => () => false); | ||
|
||
describe('SSR', () => { | ||
it('No Render in SSR', () => { | ||
const { unmount } = render( | ||
<Portal open> | ||
<div className="bamboo">Hello World</div> | ||
</Portal>, | ||
); | ||
|
||
expect(document.querySelector('.bamboo')).toBeFalsy(); | ||
|
||
unmount(); | ||
}); | ||
}); |
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,21 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Portal, { inlineMock } from '../src'; | ||
|
||
describe('Test Env', () => { | ||
it('inlineMock', () => { | ||
inlineMock(true); | ||
|
||
const { container } = render( | ||
<> | ||
Start | ||
<Portal open> | ||
<div className="bamboo">Hello World</div> | ||
</Portal> | ||
End | ||
</>, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |