• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 3d7d6f6b2bab9604d7575991225a4a9178614e04

22 Jan 2026 01:34PM UTC coverage: 42.145%. First build
3d7d6f6b2bab9604d7575991225a4a9178614e04

Pull #22887

github

web-flow
Merge 5f73610dd into 51865041f
Pull Request #22887: Refactor FAQ and How-to blocks

2732 of 9905 branches covered (27.58%)

Branch coverage included in aggregate %.

62 of 135 new or added lines in 14 files covered. (45.93%)

23283 of 51822 relevant lines covered (44.93%)

4.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.44
/packages/js/src/structured-data-blocks/shared-utils/migrationHelpers270.js
1
import { renderToString } from "@wordpress/element";
2

3
/**
4
 * Converts a rich text children array to an HTML string.
5
 *
6
 * @param {Array|string} value The value to convert.
7
 * @returns {string} The HTML string.
8
 */
9
export const childrenToString = ( value ) => {
2✔
10
        if ( ! value ) {
50✔
11
                return "";
10✔
12
        }
13
        if ( typeof value === "string" ) {
40✔
14
                return value;
8✔
15
        }
16
        if ( Array.isArray( value ) ) {
32✔
17
                try {
26✔
18
                        return renderToString( value );
26✔
19
                } catch ( e ) {
20
                        // Fallback: join string parts.
21
                        return value
2✔
22
                                .map( ( item ) => {
23
                                        if ( typeof item === "string" ) {
6✔
24
                                                return item;
4✔
25
                                        }
26
                                        if ( item && item.props ) {
2!
NEW
27
                                                return renderToString( item );
×
28
                                        }
29
                                        return "";
2✔
30
                                } )
31
                                .join( "" );
32
                }
33
        }
34
        return "";
6✔
35
};
36

37
/**
38
 * Builds an image object from a node.
39
 * @param {Object} node The image node.
40
 * @returns {{type: string, key: null, props: {src: string, alt: string, className: string, style: ""}}} The image object.
41
 */
42
const buildImageObject = ( node ) => {
2✔
43
        const { key, props = {} } = node;
26✔
44
        const { src = "", alt = "", className = "", style = "" } = props;
26✔
45

46
        return {
26✔
47
                type: "img",
48
                key,
49
                props: { src, alt, className, style },
50
        };
51
};
52

53
/**
54
 * Extracts image elements from an old array-based text field.
55
 *
56
 * @param {Array} textArray The old text array that may contain image elements.
57
 * @returns {Object[]} Array of image objects in the new format.
58
 */
59
const extractImagesFromTextArray = ( textArray ) => {
2✔
60
        if ( ! Array.isArray( textArray ) ) {
26!
NEW
61
                return [];
×
62
        }
63

64
        return textArray
26✔
65
                .filter( ( node ) => node && node.type && node.type === "img" )
46✔
66
                .map( buildImageObject );
67
};
68

69

70
/**
71
 * Gets the image array for a step, extracting from text if necessary.
72
 * @param {Object[]} imageArray The existing images array.
73
 * @param {Array|string} content The text content to extract images from if needed.
74
 * @returns {Object[]} The image array.
75
 */
76
export const getImageArray = ( imageArray, content ) => {
2✔
77
        if ( Array.isArray( content ) && imageArray.length === 0 ) {
38✔
78
                imageArray = extractImagesFromTextArray( content );
26✔
79
        }
80
        return imageArray;
38✔
81
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc