Skip to content

Commit

Permalink
fix: make toHaveTextContent() handle arrays and strings better
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarroll22 committed Apr 8, 2019
1 parent 8e11cbd commit 77659f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/to-have-text-content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { matcherHint } from 'jest-matcher-utils';
import { compose, defaultTo, join, map, path } from 'ramda';
import { compose, defaultTo, is, join, map, path } from 'ramda';

import { checkReactElement, getMessage, matches, normalize } from './utils';

Expand Down Expand Up @@ -27,7 +27,7 @@ export function toHaveTextContent(element, checkWith) {
// step 5: map the array to get text content
map(child => (typeof child === 'object' ? getText(child) : child)),
// step 4: make sure non-array children end up in an array
Array.from,
child => (is(Array, child) ? child : [child]),
// step 3: default to an array
defaultTo([]),
// step 2: drill down to the children
Expand Down

0 comments on commit 77659f7

Please sign in to comment.