Skip to content

Commit

Permalink
workaround symbol export not working in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsavona committed Oct 14, 2022
1 parent 49308b9 commit 25f6c1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 13 additions & 2 deletions packages/react-reconciler/src/__tests__/useMemoCache-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const {REACT_MEMO_CACHE_SENTINEL} = require('shared/ReactSymbols');
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/

let React;
let ReactNoop;
let act;
let useState;
let useMemoCache;
let MemoCacheSentinel;
let ErrorBoundary;

describe('useMemoCache()', () => {
Expand All @@ -16,6 +25,7 @@ describe('useMemoCache()', () => {
act = require('jest-react').act;
useState = React.useState;
useMemoCache = React.unstable_useMemoCache;
MemoCacheSentinel = Symbol.for('react.memo_cache_sentinel');

class _ErrorBoundary extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -48,7 +58,8 @@ describe('useMemoCache()', () => {
const cache = useMemoCache(1);
expect(Array.isArray(cache)).toBe(true);
expect(cache.length).toBe(1);
expect(cache[0]).toBe(REACT_MEMO_CACHE_SENTINEL);
expect(cache[0]).toBe(MemoCacheSentinel);

return 'Ok';
}
const root = ReactNoop.createRoot();
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
REACT_SCOPE_TYPE,
REACT_CACHE_TYPE,
REACT_TRACING_MARKER_TYPE,
REACT_MEMO_CACHE_SENTINEL,
} from 'shared/ReactSymbols';

import {Component, PureComponent} from './ReactBaseClasses';
Expand Down Expand Up @@ -140,7 +139,6 @@ export {
REACT_CACHE_TYPE as unstable_Cache,
use as experimental_use,
useMemoCache as unstable_useMemoCache,
REACT_MEMO_CACHE_SENTINEL as unstable_MemoCacheSentinel,
// enableScopeAPI
REACT_SCOPE_TYPE as unstable_Scope,
// enableTransitionTracing
Expand Down

0 comments on commit 25f6c1f

Please sign in to comment.