Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added a couple of additional tests
  • Loading branch information
bvaughn committed Feb 11, 2018
commit f111111ea932ad4ad01559abfb9396b82b32959c
12 changes: 12 additions & 0 deletions packages/react-is/src/__tests__/ReactIs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ describe('ReactIs', () => {
ReactIs = require('react-is');
});

it('should return undefined for unknown/invalid types', () => {
expect(ReactIs.typeOf('abc')).toBe(undefined);
expect(ReactIs.typeOf(true)).toBe(undefined);
expect(ReactIs.typeOf(123)).toBe(undefined);
expect(ReactIs.typeOf({})).toBe(undefined);
expect(ReactIs.typeOf(null)).toBe(undefined);
expect(ReactIs.typeOf(undefined)).toBe(undefined);
});

it('should identify async mode', () => {
expect(ReactIs.typeOf(<React.unstable_AsyncMode />)).toBe(
ReactIs.AsyncMode,
Expand Down Expand Up @@ -54,6 +63,9 @@ describe('ReactIs', () => {
expect(ReactIs.isElement('div')).toBe(false);
expect(ReactIs.isElement(true)).toBe(false);
expect(ReactIs.isElement(123)).toBe(false);
expect(ReactIs.isElement(null)).toBe(false);
expect(ReactIs.isElement(undefined)).toBe(false);
expect(ReactIs.isElement({})).toBe(false);

// It should also identify more specific types as elements
const Context = React.createContext(false);
Expand Down