mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 05:47:10 -04:00
feat(new-tool): diff of two json objects
This commit is contained in:
parent
61ece2387f
commit
362f2fa280
12 changed files with 751 additions and 134 deletions
39
src/tools/json-diff/json-diff.e2e.spec.ts
Normal file
39
src/tools/json-diff/json-diff.e2e.spec.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Tool - JSON diff', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/json-diff');
|
||||
});
|
||||
|
||||
test('Has correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle('JSON diff - IT Tools');
|
||||
});
|
||||
|
||||
test('Identical JSONs have a custom result message', async ({ page }) => {
|
||||
await page.getByTestId('leftJson').fill('{"foo":"bar"}');
|
||||
await page.getByTestId('rightJson').fill('{ "foo": "bar" } ');
|
||||
|
||||
const result = await page.getByTestId('diff-result').innerText();
|
||||
|
||||
expect(result).toContain('The provided JSONs are the same');
|
||||
});
|
||||
|
||||
test('Different JSONs have differences listed', async ({ page }) => {
|
||||
await page.getByTestId('leftJson').fill('{"foo":"bar"}');
|
||||
await page.getByTestId('rightJson').fill('{"foo":"buz","baz":"qux"}');
|
||||
|
||||
const result = await page.getByTestId('diff-result').innerText();
|
||||
|
||||
expect(result).toContain(`{\nfoo: "bar""buz",\nbaz: "qux",\n},`);
|
||||
});
|
||||
|
||||
test('Different JSONs have only differences listed when "Only show differences" is checked', async ({ page }) => {
|
||||
await page.getByTestId('leftJson').fill('{"foo":"bar"}');
|
||||
await page.getByTestId('rightJson').fill('{"foo":"bar","baz":"qux"}');
|
||||
await page.getByRole('switch').click();
|
||||
|
||||
const result = await page.getByTestId('diff-result').innerText();
|
||||
|
||||
expect(result).toContain(`{\nbaz: "qux",\n},`);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue