aboutsummaryrefslogtreecommitdiff
path: root/src/tools/json-to-csv/json-to-csv.e2e.spec.ts
blob: 840469cfcf78caecee2631a1629621f8cf8fa135 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { expect, test } from '@playwright/test';

test.describe('Tool - JSON to CSV', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/json-to-csv');
  });

  test('Has correct title', async ({ page }) => {
    await expect(page).toHaveTitle('JSON to CSV - IT Tools');
  });

  test('Provided json is converted to csv', async ({ page }) => {
    await page.getByTestId('input').fill(`
[
  {'Age': 18.0, 'Salary': 20000.0, 'Gender': 'Male', 'Country': 'Germany', 'Purchased': 'N'},
  {'Age': 19.0, 'Salary': 22000.0, 'Gender': 'Female', 'Country': 'France', 'Purchased': 'N'},
]
    `);

    const generatedJson = await page.getByTestId('area-content').innerText();

    expect(generatedJson.trim()).toEqual(`
Age,Salary,Gender,Country,Purchased
18,20000,Male,Germany,N
19,22000,Female,France,N
   `.trim(),
    );
  });
});