Add a null type test for memo (#14325)
chun shang committed
Nov 27, 2018 at 21:25 UTC
48f1e5b3ced33aa2d5ba42afa38af9cf7e51a0ed
2 files changed
+10
-2
packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js
+9
-1
@@ -306,13 +306,21 @@ describe('memo', () => {
306
expect(ReactNoop.getChildren()).toEqual([span(20)]);
307
});
308
309
- it('warns if first argument is undefined', () => {
309
+ it('warns if the first argument is undefined', () => {
310
expect(() => memo()).toWarnDev(
311
'memo: The first argument must be a component. Instead ' +
312
'received: undefined',
313
{withoutStack: true},
314
);
315
});
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
+ });
324
});
325
}
326
});
scripts/jest/matchers/toWarnDev.js
+1
-1
@@ -130,7 +130,7 @@ const createMatcherFor = consoleMethod =>
130
};
131
132
// 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,
134
// And throw an error.
135
const originalMethod = console[consoleMethod];
136