From d450f3b38c427fc9dce4fd4e43635a88e84d357b Mon Sep 17 00:00:00 2001 From: ShareVB Date: Fri, 22 Aug 2025 09:04:40 +0200 Subject: [PATCH] fixup! feat(new tool): Env Variables Converter --- .../lib/inputHandler.test.js | 51 +++++++------------ .../lib/outputFormatter.test.js | 28 +++++----- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/src/tools/env-variables-converter/lib/inputHandler.test.js b/src/tools/env-variables-converter/lib/inputHandler.test.js index 42825774..74e52873 100644 --- a/src/tools/env-variables-converter/lib/inputHandler.test.js +++ b/src/tools/env-variables-converter/lib/inputHandler.test.js @@ -1,19 +1,20 @@ -import { describe, expect } from 'vitest'; -import { Formats } from '../components/home/main/Main'; +import { describe, expect, it } from 'vitest'; +import { Formats } from './formats'; import inputHandler from './inputHandler'; -describe('simplifies input', () => { - const input = ` - name: SPRING_CACHE_TYPE +describe('inputHandler', () => { + it('simplifies input', () => { + const input = ` - name: SPRING_CACHE_TYPE value: redis - name: SPRING_REDIS_SSL value: true`; - expect(inputHandler(Formats.KUBERNETES, input)) - .toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' }); -}); + expect(inputHandler(Formats.KUBERNETES, input)) + .toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' }); + }); -// https://stackoverflow.com/a/21699210/1098564 -describe('simplifies input quotations', () => { - const input = ` + // https://stackoverflow.com/a/21699210/1098564 + it('simplifies input quotations', () => { + const input = ` - name: SPRING_CACHE_TYPE value: redis - name: >- @@ -30,31 +31,17 @@ describe('simplifies input quotations', () => { SPRING_REDIS_SSL3 value: 'redis'`; - expect(inputHandler(Formats.KUBERNETES, input)) - .toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' }); -}); + expect(inputHandler(Formats.KUBERNETES, input)) + .toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' }); + }); -// // https://stackoverflow.com/a/21699210/1098564 -// test('block style chomp strip', () => { -// const input = ` -// - name: SOME_KEY -// value: >- -// very "long" -// 'string' with - -// paragraph gap, \n and -// spaces. -// ` -// expect(inputHandler(Formats.KUBERNETES, input)) -// .toStrictEqual({"SOME_KEY": "very \"long\" 'string' with\nparagraph gap, \\n and spaces."}); -// }); - -describe('simplifies input properties quotes', () => { - const input = `foo-bar.baz[0]=value1 + it('simplifies input properties quotes', () => { + const input = `foo-bar.baz[0]=value1 foo-bar.baz[1]=value2 foo-bar.enabled=true abcDef=value3 `; - expect(inputHandler(Formats.PROPERTIES, input)) - .toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } }); + expect(inputHandler(Formats.PROPERTIES, input)) + .toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } }); + }); }); diff --git a/src/tools/env-variables-converter/lib/outputFormatter.test.js b/src/tools/env-variables-converter/lib/outputFormatter.test.js index 4a4e51a9..d691d899 100644 --- a/src/tools/env-variables-converter/lib/outputFormatter.test.js +++ b/src/tools/env-variables-converter/lib/outputFormatter.test.js @@ -1,33 +1,34 @@ -import { describe, expect } from 'vitest'; -import { Formats } from '../formats'; +import { describe, expect, it } from 'vitest'; +import { Formats } from './formats'; import outputFormatter from './outputFormatter'; -describe('yaml format', () => { - const input = `foo-bar.baz[0]=value1 +describe('outputFormatter', () => { + it('yaml format', () => { + const input = `foo-bar.baz[0]=value1 foo-bar.baz[1]=value2 foo-bar.enabled=true abcDef=value3 -`.split('\n'); + `.split('\n'); - expect(outputFormatter(Formats.YAML, input)) - .toStrictEqual( -`foo-bar: + expect(outputFormatter(Formats.YAML, input)) + .toStrictEqual( + `foo-bar: baz: - value1 - value2 enabled: true abcDef: value3 `); -}); + }); -describe('k8s format', () => { - const input = `foo-bar.baz[0]=value1 + it('k8s format', () => { + const input = `foo-bar.baz[0]=value1 foo-bar.baz[1]=value2 foo-bar.enabled=true abcDef=value3`.split('\n'); - expect(outputFormatter(Formats.KUBERNETES, input)) - .toStrictEqual( + expect(outputFormatter(Formats.KUBERNETES, input)) + .toStrictEqual( `- name: FOOBAR_BAZ_0_ value: 'value1' - name: FOOBAR_BAZ_1_ @@ -37,4 +38,5 @@ abcDef=value3`.split('\n'); - name: ABCDEF value: 'value3' `); + }); });