+/**
+ * Expect a given prop within the JSON editor state structure to be the given value.
+ * Uses dot notation for the provided `propPath`. Example:
+ * 0.5.cat => First child, Sixth child, cat property
+ */
+export function expectEditorStateJSONPropToEqual(editor: LexicalEditor, propPath: string, expected: any) {
+ let currentItem: any = editor.getEditorState().toJSON().root;
+ let currentPath = [];
+ const pathParts = propPath.split('.');
+
+ for (const part of pathParts) {
+ currentPath.push(part);
+ const childAccess = Number.isInteger(Number(part)) && Array.isArray(currentItem.children);
+ const target = childAccess ? currentItem.children : currentItem;
+
+ if (typeof target[part] === 'undefined') {
+ throw new Error(`Could not resolve editor state at path ${currentPath.join('.')}`)
+ }
+ currentItem = target[part];
+ }
+
+ expect(currentItem).toBe(expected);
+}
+