From 746e5bdcccb37a39d1b46fc83740e881e49aa9b1 Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Fri, 23 Jun 2023 21:39:37 +0200 Subject: [PATCH] feat(new-tool): toml to yaml --- src/tools/index.ts | 2 ++ src/tools/toml-to-yaml/index.ts | 12 +++++++ .../toml-to-yaml/toml-to-yaml.e2e.spec.ts | 36 +++++++++++++++++++ src/tools/toml-to-yaml/toml-to-yaml.vue | 27 ++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 src/tools/toml-to-yaml/index.ts create mode 100644 src/tools/toml-to-yaml/toml-to-yaml.e2e.spec.ts create mode 100644 src/tools/toml-to-yaml/toml-to-yaml.vue diff --git a/src/tools/index.ts b/src/tools/index.ts index 22b3b53a..1bf41c27 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,6 +1,7 @@ import { tool as base64FileConverter } from './base64-file-converter'; import { tool as base64StringConverter } from './base64-string-converter'; import { tool as basicAuthGenerator } from './basic-auth-generator'; +import { tool as tomlToYaml } from './toml-to-yaml'; import { tool as tomlToJson } from './toml-to-json'; import { tool as jsonToCsv } from './json-to-csv'; import { tool as cameraRecorder } from './camera-recorder'; @@ -82,6 +83,7 @@ export const toolsByCategory: ToolCategory[] = [ jsonToYaml, listConverter, tomlToJson, + tomlToYaml, ], }, { diff --git a/src/tools/toml-to-yaml/index.ts b/src/tools/toml-to-yaml/index.ts new file mode 100644 index 00000000..69f9459c --- /dev/null +++ b/src/tools/toml-to-yaml/index.ts @@ -0,0 +1,12 @@ +import { defineTool } from '../tool'; +import BracketIcon from '~icons/mdi/code-brackets'; + +export const tool = defineTool({ + name: 'TOML to YAML', + path: '/toml-to-yaml', + description: 'Parse and convert TOML to YAML.', + keywords: ['toml', 'yaml', 'convert', 'online', 'transform', 'parse'], + component: () => import('./toml-to-yaml.vue'), + icon: BracketIcon, + createdAt: new Date('2023-06-23'), +}); diff --git a/src/tools/toml-to-yaml/toml-to-yaml.e2e.spec.ts b/src/tools/toml-to-yaml/toml-to-yaml.e2e.spec.ts new file mode 100644 index 00000000..87fd20a9 --- /dev/null +++ b/src/tools/toml-to-yaml/toml-to-yaml.e2e.spec.ts @@ -0,0 +1,36 @@ +import { expect, test } from '@playwright/test'; + +test.describe('Tool - TOML to YAML', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/toml-to-yaml'); + }); + + test('Has correct title', async ({ page }) => { + await expect(page).toHaveTitle('TOML to YAML - IT Tools'); + }); + + test('TOML is parsed and outputs clean YAML', async ({ page }) => { + await page.getByTestId('input').fill(` +foo = "bar" + +# This is a comment + +[list] + name = "item" +[list.another] + key = "value" + `.trim()); + + const generatedJson = await page.getByTestId('area-content').innerText(); + + expect(generatedJson.trim()).toEqual( + ` +foo: bar +list: + name: item + another: + key: value + `.trim(), + ); + }); +}); diff --git a/src/tools/toml-to-yaml/toml-to-yaml.vue b/src/tools/toml-to-yaml/toml-to-yaml.vue new file mode 100644 index 00000000..ec4e0158 --- /dev/null +++ b/src/tools/toml-to-yaml/toml-to-yaml.vue @@ -0,0 +1,27 @@ + + +