All files / src/helpers findComponent.js

100% Statements 10/10
50% Branches 1/2
100% Functions 6/6
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22              23x 80x     23x 28x             82x   28x
import { COMPONENTS } from '../constants'
 
/**
 * 
 * @param {Array<VNode>} children - nested Vue components
 * @returns {Object | null} cld-placeholder component if found.
 */
export const getCldPlaceholder = (children = []) => {
 return children?.find(child => isCldPlaceholder(child))
}
 
export const getCldPoster = (children = []) => {
 return children?.find(child => isCldPoster(child))
}
 
/**
* @param {VNode} component 
* @returns {Boolean} true if component is CldPlaceholder
*/
export const isCldPlaceholder = (component) => component.componentOptions?.Ctor?.extendOptions?.name === COMPONENTS.CldPlaceholder
 
export const isCldPoster = (component) => component.componentOptions?.Ctor?.extendOptions?.name === COMPONENTS.CldPoster