-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4a5fbe
commit 51c688b
Showing
14 changed files
with
207 additions
and
700 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
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
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
24 changes: 21 additions & 3 deletions
24
packages/big-design/src/components/Worksheet/hooks/useUpdateItems/spec.tsx
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,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; | ||
} | ||
}, | ||
}); | ||
|
||
expect(hook.error?.message).toContain('UpdateItemsProvider'); | ||
expect(error).toEqual(new Error('useUpdateItems must be used within an <UpdateItemsProvider>')); | ||
}); |
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
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
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
Oops, something went wrong.