From bed8a11b5da65413f5ee53e29d2f214ad04dd4fa Mon Sep 17 00:00:00 2001 From: Amirhossein Alibakhshi Date: Sun, 21 Jul 2024 11:39:46 +0330 Subject: [PATCH] refacor: move tests next together --- src/builder/JsonSchemaBuilder.ts | 50 ------------------- .../JsonSchemaBuilder.test.ts | 2 +- src/{utils => test}/utils.test.ts | 2 +- 3 files changed, 2 insertions(+), 52 deletions(-) rename src/{builder => test}/JsonSchemaBuilder.test.ts (98%) rename src/{utils => test}/utils.test.ts (98%) diff --git a/src/builder/JsonSchemaBuilder.ts b/src/builder/JsonSchemaBuilder.ts index 1345aa0..eef2cf9 100644 --- a/src/builder/JsonSchemaBuilder.ts +++ b/src/builder/JsonSchemaBuilder.ts @@ -58,56 +58,6 @@ export class JsonSchemaBuilder { } } - // private deleteNestedPropertyByPath = (obj: JsonSchema, path: string): JsonSchema => { - // const keys = path.split('.'); - // const newObject = { ...obj }; - // - // if (keys.length === 0) { - // return newObject; - // } - // - // let current = newObject; - // const stack = []; - // - // for (let i = 0; i < keys.length - 1; i++) { - // stack.push(current); //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // current[keys[i]] = { ...current[keys[i]] }; //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // current = current[keys[i]]; - // } - // //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // delete current[keys[keys.length - 1]]; - // - // for (let i = keys.length - 2; i >= 0; i--) { - // const key = keys[i]; //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // - // current = stack.pop(); //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // if (Object.keys(current[key]).length === 0) {//@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // delete current[key]; - // } - // } - // - // return newObject; - // }; - // - // private updateNestedObjectByPath = (obj: JsonSchema, path: string, value: unknown): JsonSchema => { - // console.log('🐕 sag path', path); // TODO: REMOVE ME ⚠️ - // - // const keys = path.split('.'); - // const newObject = { ...obj }; - // - // let current = newObject; - // keys.forEach((key, index) => { - // if (index === keys.length - 1) { //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // current[key] = value; - // } else { //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // current[key] = current[key] ? { ...current[key] } : {}; //@ts-expect-error // eslint-disable-line @typescript-eslint/ban-ts-comment - // current = current[key]; - // } - // }); - // - // return newObject; - // }; - private deleteNestedPropertyByPath = (obj: JsonSchema, path: string): JsonSchema => { const keys = path.split('.'); const newObject = { ...obj }; diff --git a/src/builder/JsonSchemaBuilder.test.ts b/src/test/JsonSchemaBuilder.test.ts similarity index 98% rename from src/builder/JsonSchemaBuilder.test.ts rename to src/test/JsonSchemaBuilder.test.ts index e848d22..3e599ee 100644 --- a/src/builder/JsonSchemaBuilder.test.ts +++ b/src/test/JsonSchemaBuilder.test.ts @@ -1,4 +1,4 @@ -import { JsonSchemaBuilder } from './JsonSchemaBuilder'; +import { JsonSchemaBuilder } from '../builder/JsonSchemaBuilder'; import { SCHEMA_TYPE } from '../constants'; import { Format, JsonSchema } from '../types'; diff --git a/src/utils/utils.test.ts b/src/test/utils.test.ts similarity index 98% rename from src/utils/utils.test.ts rename to src/test/utils.test.ts index c0d4e30..2f4af3a 100644 --- a/src/utils/utils.test.ts +++ b/src/test/utils.test.ts @@ -1,4 +1,4 @@ -import { accessToObjectFieldByPath, accessToObjectFieldParentByPath } from './index'; // Adjust the import to match your file structure +import { accessToObjectFieldByPath, accessToObjectFieldParentByPath } from '../utils'; // Adjust the import to match your file structure describe('accessToObjectFieldByPath', () => { const testObject = {