mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
feat: json to typescript
This commit is contained in:
parent
9eac9cb2a9
commit
dd03874556
11 changed files with 7008 additions and 5266 deletions
45
src/tools/json-to-ts/json-to-ts.e2e.spec.ts
Normal file
45
src/tools/json-to-ts/json-to-ts.e2e.spec.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test.describe('Tool - JSON to TS', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/json-to-ts');
|
||||
});
|
||||
|
||||
test('Has correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle('JSON to TS - IT Tools');
|
||||
});
|
||||
|
||||
test('JSON is parsed and outputs clean TS', async ({ page }) => {
|
||||
await page.getByTestId('input').fill(`
|
||||
{
|
||||
"foo": "bar",
|
||||
"list": {
|
||||
"name": "item",
|
||||
"another": {
|
||||
"key": "value"
|
||||
}
|
||||
}
|
||||
}
|
||||
`.trim());
|
||||
|
||||
const generatedJson = await page.getByTestId('area-content').innerText();
|
||||
|
||||
expect(generatedJson.trim()).toEqual(
|
||||
`
|
||||
interface DataProps {
|
||||
foo: string;
|
||||
list: List;
|
||||
}
|
||||
|
||||
interface List {
|
||||
name: string;
|
||||
another: Another;
|
||||
}
|
||||
|
||||
interface Another {
|
||||
key: string;
|
||||
}
|
||||
`.trim(),
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue