-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(deps): react@18 support #981
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { ArrowBackIcon, ArrowForwardIcon, DeleteIcon } from '@bigcommerce/big-design-icons'; | ||
import { remCalc } from '@bigcommerce/big-design-theme'; | ||
import { act, fireEvent, render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import 'jest-styled-components'; | ||
import React, { createRef } from 'react'; | ||
|
||
|
@@ -546,10 +547,9 @@ test('closing the Select triggers onClose', async () => { | |
|
||
const button = await screen.findByLabelText('toggle menu'); | ||
|
||
await act(async () => { | ||
await fireEvent.click(button); | ||
await fireEvent.click(button); | ||
}); | ||
await userEvent.click(button); | ||
|
||
await userEvent.click(button); | ||
Comment on lines
+550
to
+552
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test was failing with |
||
|
||
expect(onClose).toHaveBeenCalled(); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { renderHook } from '@testing-library/react'; | ||
import { Component, PropsWithChildren } from 'react'; | ||
|
||
import { useUpdateItems } from './index'; | ||
|
||
beforeEach(() => { | ||
// We need to suppress console errors, otherwise we'll blow up the console. | ||
// eslint-disable-next-line no-console | ||
console.error = jest.fn(); | ||
}); | ||
|
||
test('throws if is not wrapped in UpdateItemsProvider', () => { | ||
const { result: hook } = renderHook(() => useUpdateItems()); | ||
let error; | ||
|
||
renderHook(() => useUpdateItems(), { | ||
wrapper: class Wrapper extends Component<PropsWithChildren<unknown>> { | ||
override componentDidCatch(err: unknown) { | ||
error = err; | ||
} | ||
override render() { | ||
return this.props.children; | ||
} | ||
}, | ||
}); | ||
|
||
Comment on lines
+15
to
25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When they ported over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😵💫 |
||
expect(hook.error?.message).toContain('UpdateItemsProvider'); | ||
expect(error).toEqual(new Error('useUpdateItems must be used within an <UpdateItemsProvider>')); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Small, Text } from '@bigcommerce/big-design'; | ||
import { Small } from '@bigcommerce/big-design'; | ||
import React from 'react'; | ||
|
||
import { Prop, PropTable, PropTableWrapper } from '../components'; | ||
|
@@ -18,8 +18,11 @@ const alertProps: Prop[] = [ | |
defaultValue: 'false', | ||
description: ( | ||
<> | ||
<Text>Auto dismiss after 5 seconds.</Text> | ||
<Small>Note: Only valid when used with AlertManager.</Small> | ||
Auto dismiss after 5 seconds. | ||
{/* I hate using a br but the as prop doesn't support div for now */} | ||
{/* TODO: Support div for as prop */} | ||
<br /> | ||
<Small as="span">Note: Only valid when used with AlertManager.</Small> | ||
Comment on lines
+21
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :cringe: |
||
</> | ||
), | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Small, Text } from '@bigcommerce/big-design'; | ||
import { Small } from '@bigcommerce/big-design'; | ||
import React from 'react'; | ||
|
||
import { NextLink, Prop, PropTable, PropTableWrapper } from '../components'; | ||
|
@@ -64,8 +64,11 @@ const boxProps: Prop[] = [ | |
types: ['sticky', 'fixed', 'modalBackdrop', 'modal', 'tooltip', 'popover'], | ||
description: ( | ||
<> | ||
<Text>Determines type of z-index to be applied.</Text> | ||
<Small>Types are in order (sticky is low, popover is high).</Small> | ||
Determines type of z-index to be applied. | ||
{/* I hate using a br but the as prop doesn't support div for now */} | ||
{/* TODO: Support div for as prop */} | ||
<br /> | ||
<Small as="span">Types are in order (sticky is low, popover is high).</Small> | ||
Comment on lines
+67
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</> | ||
), | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,9 @@ const defaultScope = { | |
styled, | ||
}; | ||
|
||
function getInitialCode(children: React.ReactNode, language: Language): string { | ||
type CodePreviewChildren = React.ReactNode | (() => JSX.Element); | ||
|
||
function getInitialCode(children: CodePreviewChildren, language: Language): string { | ||
if (typeof children !== 'string') { | ||
throw new Error('<CodePreview> children must be of type string'); | ||
} | ||
|
@@ -61,7 +63,7 @@ function transformCode(input: string): string { | |
} | ||
|
||
export interface CodePreviewProps { | ||
children?: React.ReactNode; | ||
children?: CodePreviewChildren; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 |
||
scope?: { [key: string]: unknown }; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,9 @@ const ColorCard: React.FC<ColorCardProps> = ({ colorCard }) => { | |
{description.text}{' '} | ||
{Boolean(description.href) && ( | ||
<Link href={description.href} target="_blank"> | ||
<Small color="inherit">Read more</Small> | ||
<Small as="span" color="inherit"> | ||
Read more | ||
</Small> | ||
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</Link> | ||
)} | ||
</Small> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I bumped
@testing-library/react
, theirunmount
method completely wipescontainer.innerhtml
so we just need to userender
instead.rerender
is really only useful for updates to props.