Skip to content

Commit 48f1e5b

Browse files
springupergaearon
authored andcommitted
Add a null type test for memo (#14325)
1 parent f93f340 commit 48f1e5b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,21 @@ describe('memo', () => {
306306
expect(ReactNoop.getChildren()).toEqual([span(20)]);
307307
});
308308

309-
it('warns if first argument is undefined', () => {
309+
it('warns if the first argument is undefined', () => {
310310
expect(() => memo()).toWarnDev(
311311
'memo: The first argument must be a component. Instead ' +
312312
'received: undefined',
313313
{withoutStack: true},
314314
);
315315
});
316+
317+
it('warns if the first argument is null', () => {
318+
expect(() => memo(null)).toWarnDev(
319+
'memo: The first argument must be a component. Instead ' +
320+
'received: null',
321+
{withoutStack: true},
322+
);
323+
});
316324
});
317325
}
318326
});

scripts/jest/matchers/toWarnDev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const createMatcherFor = consoleMethod =>
130130
};
131131

132132
// TODO Decide whether we need to support nested toWarn* expectations.
133-
// If we don't need id, add a check here to see if this is already our spy,
133+
// If we don't need it, add a check here to see if this is already our spy,
134134
// And throw an error.
135135
const originalMethod = console[consoleMethod];
136136

0 commit comments

Comments
 (0)