Compare commits

...

4 Commits

2 changed files with 10 additions and 11 deletions

View File

@@ -92,14 +92,14 @@ function BodyTitleRenderer({
if (isObject) { if (isObject) {
// For objects/arrays, stringify the entire structure // For objects/arrays, stringify the entire structure
copyText = `"${cleanedKey}": ${JSON.stringify(value, null, 2)}`; copyText = JSON.stringify(value, null, 2);
} else if (parentIsArray) { } else if (parentIsArray) {
// For array elements, copy just the value // array elements
copyText = `"${cleanedKey}": ${value}`; copyText = `${value}`;
} else { } else {
// For primitive values, format as JSON key-value pair // primitive values
const valueStr = typeof value === 'string' ? `"${value}"` : String(value); const valueStr = typeof value === 'string' ? value : String(value);
copyText = `"${cleanedKey}": ${valueStr}`; copyText = valueStr;
} }
setCopy(copyText); setCopy(copyText);

View File

@@ -51,7 +51,7 @@ describe('BodyTitleRenderer', () => {
await user.click(screen.getByText('name')); await user.click(screen.getByText('name'));
await waitFor(() => { await waitFor(() => {
expect(mockSetCopy).toHaveBeenCalledWith('"user.name": "John"'); expect(mockSetCopy).toHaveBeenCalledWith('John');
expect(mockNotification).toHaveBeenCalledWith( expect(mockNotification).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
message: expect.stringContaining('user.name'), message: expect.stringContaining('user.name'),
@@ -75,7 +75,7 @@ describe('BodyTitleRenderer', () => {
await user.click(screen.getByText('0')); await user.click(screen.getByText('0'));
await waitFor(() => { await waitFor(() => {
expect(mockSetCopy).toHaveBeenCalledWith('"items[*].0": arrayElement'); expect(mockSetCopy).toHaveBeenCalledWith('arrayElement');
}); });
}); });
@@ -96,9 +96,8 @@ describe('BodyTitleRenderer', () => {
await waitFor(() => { await waitFor(() => {
const callArg = mockSetCopy.mock.calls[0][0]; const callArg = mockSetCopy.mock.calls[0][0];
expect(callArg).toContain('"user.metadata":'); const expectedJson = JSON.stringify(testObject, null, 2);
expect(callArg).toContain('"id": 123'); expect(callArg).toBe(expectedJson);
expect(callArg).toContain('"active": true');
expect(mockNotification).toHaveBeenCalledWith( expect(mockNotification).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
message: expect.stringContaining('object copied'), message: expect.stringContaining('object copied'),