-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Matchlighter-decorators2022-2
- Loading branch information
Showing
13 changed files
with
89 additions
and
4 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
{ | ||
"extends": "../tsconfig.test.json" | ||
} |
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
36 changes: 36 additions & 0 deletions
36
packages/mobx-react/__tests__/timerBasedFinalizationRegistry.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import "./utils/killFinalizationRegistry" | ||
import { cleanup, render, act } from "@testing-library/react" | ||
import * as mobx from "mobx" | ||
import * as React from "react" | ||
import { observer } from "../src" | ||
import { clearTimers } from "mobx-react-lite" | ||
|
||
expect(globalThis.FinalizationRegistry).toBeUndefined() | ||
|
||
afterEach(cleanup) | ||
|
||
test("should unregister from FinalizationRegistry once commited #3776", async () => { | ||
const o = mobx.observable({ x: 0 }) | ||
|
||
@observer | ||
class TestCmp extends React.Component<any> { | ||
render() { | ||
return o.x | ||
} | ||
} | ||
|
||
const { unmount, container } = render(<TestCmp />) | ||
|
||
expect(container).toHaveTextContent("0") | ||
|
||
// If not unregistered, clearTimes disposes reaction | ||
clearTimers() | ||
|
||
act(() => { | ||
o.x++ | ||
}) | ||
|
||
expect(container).toHaveTextContent("1") | ||
|
||
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,3 @@ | ||
{ | ||
"extends": "../tsconfig.test.json" | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/mobx-react/__tests__/utils/killFinalizationRegistry.ts
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,4 @@ | ||
// We want to be able to test reaction cleanup code that based on FinalizationRegistry & timers on the same run | ||
// For that we import this file on the beginning on the timer based test to the feature detection will pick the timers impl | ||
// @ts-ignore | ||
global.FinalizationRegistry = undefined |
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,3 @@ | ||
{ | ||
"extends": "../../../tsconfig.test.json" | ||
} |
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,3 @@ | ||
{ | ||
"extends": "../../../tsconfig.test.json" | ||
} |