# speechkit/7.0.0/src/editor/components/inspect-panel/helpers.test.js

BeyondWords – AI audio for publishers, version 7.0.0. 100 lines.

- Page: https://pluginprobe.com/plugins/speechkit/7.0.0/code/src/editor/components/inspect-panel/helpers.test.js
- Raw: https://pluginprobe.com/plugins/speechkit/7.0.0/raw/src/editor/components/inspect-panel/helpers.test.js
- Modified: 2026-08-12T09:46:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/speechkit/7.0.0/code/src/editor/components/inspect-panel/helpers.test.js#L10-L20`.

```javascript
/* global describe, it, expect */

/**
 * Internal dependencies
 */
import { SYSTEM_META_KEYS, hasBeyondwordsData, getTextToCopy } from './helpers';

// Representative subset of the key lists PHP supplies via the settings store.
const CURRENT = [ 'beyondwords_generate_audio', 'beyondwords_content_id' ];
const DEPRECATED = [ 'speechkit_podcast_id' ];
const DATA_KEYS = [ ...CURRENT, ...DEPRECATED ];

describe( 'hasBeyondwordsData', () => {
	it( 'is false when none of the data keys are populated', () => {
		expect( hasBeyondwordsData( {}, DATA_KEYS ) ).toBe( false );
	} );

	it( 'ignores keys outside the supplied list (e.g. system fields)', () => {
		expect(
			hasBeyondwordsData(
				{ plugin_version: '5.0.0', wp_version: '6.5', wp_post_id: 123 },
				DATA_KEYS
			)
		).toBe( false );
	} );

	it( 'is true when a current data key is populated', () => {
		expect(
			hasBeyondwordsData( { beyondwords_content_id: '12345' }, DATA_KEYS )
		).toBe( true );
	} );

	it( 'is true when only a deprecated data key is populated', () => {
		expect(
			hasBeyondwordsData( { speechkit_podcast_id: '999' }, DATA_KEYS )
		).toBe( true );
	} );

	it( 'treats empty strings as no data', () => {
		const empty = { beyondwords_content_id: '', speechkit_podcast_id: '' };
		expect( hasBeyondwordsData( empty, DATA_KEYS ) ).toBe( false );
	} );

	it( 'reflects data added after mount (the stale-snapshot regression)', () => {
		expect(
			hasBeyondwordsData( { plugin_version: '5.0.0' }, DATA_KEYS )
		).toBe( false );
		expect(
			hasBeyondwordsData( { beyondwords_content_id: '12345' }, DATA_KEYS )
		).toBe( true );
	} );

	it( 'is false before the keys load (settings not yet fetched)', () => {
		expect(
			hasBeyondwordsData( { beyondwords_content_id: '12345' } )
		).toBe( false );
	} );
} );

describe( 'getTextToCopy', () => {
	it( 'labels each field with its meta key, in the supplied order', () => {
		const text = getTextToCopy(
			{ beyondwords_content_id: '12345' },
			CURRENT,
			DEPRECATED
		);
		expect( text ).toContain( 'beyondwords_content_id\r\n12345' );
		expect( text.indexOf( 'beyondwords_content_id' ) ).toBeGreaterThan(
			text.indexOf( 'beyondwords_generate_audio' )
		);
	} );

	it( 'groups the sections in order with separators', () => {
		const text = getTextToCopy( {}, CURRENT, DEPRECATED );
		const deprecated = text.indexOf( '=== Deprecated ===' );
		const system = text.indexOf( '=== System ===' );
		expect( deprecated ).toBeGreaterThan( -1 );
		expect( system ).toBeGreaterThan( deprecated );
		expect( text ).toContain( '=== Copied using the Block Editor ===' );
	} );

	it( 'always appends the system fields', () => {
		const text = getTextToCopy(
			{ plugin_version: '5.0.0' },
			CURRENT,
			DEPRECATED
		);
		SYSTEM_META_KEYS.forEach( ( key ) => expect( text ).toContain( key ) );
		expect( text ).toContain( 'plugin_version\r\n5.0.0' );
	} );

	it( 'reads the same meta hasBeyondwordsData checks', () => {
		const meta = { beyondwords_content_id: '12345' };
		expect( getTextToCopy( meta, CURRENT, DEPRECATED ) ).toContain(
			'12345'
		);
		expect( hasBeyondwordsData( meta, DATA_KEYS ) ).toBe( true );
	} );
} );

```
