aboutsummaryrefslogtreecommitdiff
path: root/src/tools/json-diff/json-diff.e2e.spec.ts
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-04-22 00:49:03 +0200
committerGravatar Corentin THOMASSET <corentin.thomasset74@gmail.com> 2023-04-23 15:24:20 +0200
commit362f2fa280fdab210074e9a7e01dde6187924d29 (patch)
tree2a17c13e1db19e0b244cda22eabf8e107218f6b9 /src/tools/json-diff/json-diff.e2e.spec.ts
parent61ece2387f7061d67177ee41c35db572ffeb84a7 (diff)
downloadit-tools-362f2fa280fdab210074e9a7e01dde6187924d29.tar.gz
it-tools-362f2fa280fdab210074e9a7e01dde6187924d29.tar.zst
it-tools-362f2fa280fdab210074e9a7e01dde6187924d29.zip
feat(new-tool): diff of two json objects
Diffstat (limited to 'src/tools/json-diff/json-diff.e2e.spec.ts')
-rw-r--r--src/tools/json-diff/json-diff.e2e.spec.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tools/json-diff/json-diff.e2e.spec.ts b/src/tools/json-diff/json-diff.e2e.spec.ts
new file mode 100644
index 0000000..5370060
--- /dev/null
+++ b/src/tools/json-diff/json-diff.e2e.spec.ts
@@ -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},`);
+ });
+});