forked from toss/suspensive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): new internal api
SuspensiveError
(toss#615)
fix toss#598 new internal api: `SuspensiveError` to assert each hooks position for ErrorBoundary, ErrorBoundaryGroup SuspensiveError shouldn't be caught by ErrorBoundary. so I updated implementation of `<ErrorBoundary/>` ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
- Loading branch information
Showing
16 changed files
with
178 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@suspensive/react': minor | ||
--- | ||
|
||
feat(react): add SuspensiveError for useErrorBoundary, useErrorBoundaryFallbackProps, useErrorBoundaryGroup internally |
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 |
---|---|---|
|
@@ -34,4 +34,3 @@ esm | |
|
||
# graph | ||
graph/ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, expect, expectTypeOf, it } from 'vitest' | ||
import { SuspensiveError } from './SuspensiveError' | ||
|
||
describe('SuspensiveError.assert', () => { | ||
it('should make assertion if condition is boolean', () => { | ||
const isRandomlyTrue = Math.random() > 0.5 | ||
expectTypeOf(isRandomlyTrue).toEqualTypeOf<boolean>() | ||
try { | ||
SuspensiveError.assert(isRandomlyTrue, 'isRandomlyTrue should be true') | ||
expectTypeOf(isRandomlyTrue).toEqualTypeOf<true>() | ||
expect(isRandomlyTrue).toBe(true) | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(SuspensiveError) | ||
} | ||
}) | ||
it('should make assertion if condition is right', () => { | ||
const isAlwaysTrue = Math.random() > 0 | ||
expectTypeOf(isAlwaysTrue).toEqualTypeOf<boolean>() | ||
SuspensiveError.assert(isAlwaysTrue, 'isAlwaysTrue should be true') | ||
expectTypeOf(isAlwaysTrue).toEqualTypeOf<true>() | ||
expect(isAlwaysTrue).toBe(true) | ||
}) | ||
it('should throw SuspensiveError if condition is not right', () => { | ||
try { | ||
SuspensiveError.assert(Math.random() > 2, 'Math.random() should be greater than 2') | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(SuspensiveError) | ||
} | ||
}) | ||
}) |
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.