Skip to content

Commit

Permalink
fix flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Nov 4, 2019
1 parent fdb21ab commit 436c2bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/jest-emotion/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function flatMap(arr, iteratee) {
return [].concat(...arr.map(iteratee))
}

export function findLast(arr, predicate) {
export function findLast<T>(arr: T[], predicate: T => boolean) {
for (let i = arr.length - 1; i >= 0; i--) {
if (predicate(arr[i])) {
return arr[i]
Expand Down Expand Up @@ -219,7 +219,11 @@ export function hasClassNames(
// in the list of received node classNames to make sure this css rule
// applied for root element
if (!target) {
return classNames.includes(last(selector.split(' ')).slice(1))
const lastCls = last(selector.split(' '))
if (!lastCls) {
return false
}
return classNames.includes(lastCls).slice(1)
}
// check if selector (className) of specific css rule match target
return target instanceof RegExp
Expand Down

0 comments on commit 436c2bf

Please sign in to comment.