From 0dcff7ecb2cdd9650c71174c827a7638f358f31a Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 17:38:20 +0330 Subject: [PATCH 01/12] bug fixed --- src/models/schema/getFlattenPureFromRelations.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/schema/getFlattenPureFromRelations.ts b/src/models/schema/getFlattenPureFromRelations.ts index 97282bc9..beaa4194 100644 --- a/src/models/schema/getFlattenPureFromRelations.ts +++ b/src/models/schema/getFlattenPureFromRelations.ts @@ -5,7 +5,7 @@ import { TSchemas } from "./mod.ts"; export const getFlattenPureFromRelations = ( schemas: TSchemas, schemaName: string, - relationType: "MainRelations" | "RelatedRelations" | "All", + relationType: "MainRelations" | "RelatedRelations" | "All" ) => { const schema = getSchema(schemas, schemaName); let pureSchemas = {}; @@ -15,7 +15,7 @@ export const getFlattenPureFromRelations = ( pureSchemas = { ...pureSchemas, [property]: object( - schemas[schema.mainRelations[property].schemaName]?.pure, + schemas[schema.mainRelations[property].schemaName]?.pure ), }; } @@ -25,13 +25,13 @@ export const getFlattenPureFromRelations = ( pureSchemas = { ...pureSchemas, [property]: object( - schemas[schema.relatedRelations[property].schemaName]?.pure, + schemas[schema.relatedRelations[property].schemaName]?.pure ), }; } }; - if (relationType === "RelatedRelations") { + if (relationType === "MainRelations") { addMainRelation(); } if (relationType === "RelatedRelations") { From 72fee2459c8d72b6124483288c3185452fa790f4 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:02:37 +0330 Subject: [PATCH 02/12] tests for createEmbedded are added --- src/models/schema/__tests__/createEmbedded.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/models/schema/__tests__/createEmbedded.test.ts diff --git a/src/models/schema/__tests__/createEmbedded.test.ts b/src/models/schema/__tests__/createEmbedded.test.ts new file mode 100644 index 00000000..4b50ea1a --- /dev/null +++ b/src/models/schema/__tests__/createEmbedded.test.ts @@ -0,0 +1,14 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getPureFromMainRelations } from "../getPureFromMainRelations.ts"; +import { getPureFromRelatedRelations } from "../getPureFromRelatedRelations.ts"; +import { createEmbedded } from "../mod.ts"; +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/mod.ts"; +import { object } from "../../../npmDeps.ts"; + +Deno.test({ + name: "createEmbedded should return getPureFromMainRelations and getPureFromRelatedRelations from schemaMockData", + fn() { + assertInstanceOf(createEmbedded(schemaMockData, "city"), Object); + }, +}); From ec977145c35802127b7aac8fa35aa73593bd262e Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:03:39 +0330 Subject: [PATCH 03/12] tests for createStruct are added --- src/models/schema/__tests__/createStruct.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/models/schema/__tests__/createStruct.test.ts diff --git a/src/models/schema/__tests__/createStruct.test.ts b/src/models/schema/__tests__/createStruct.test.ts new file mode 100644 index 00000000..623f7537 --- /dev/null +++ b/src/models/schema/__tests__/createStruct.test.ts @@ -0,0 +1,12 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { createEmbedded, createStruct, getSchema } from "../mod.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { assign, object } from "../../../npmDeps.ts"; +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/mod.ts"; + +Deno.test({ + name: "getPureSchema should return schema.pure from schemaMockData", + fn() { + assertInstanceOf(createStruct(schemaMockData, "city"), Object); + }, +}); From 57e4cd99dec0bde18453e3be779f365f21248f3d Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:04:36 +0330 Subject: [PATCH 04/12] added return to setService --- src/acts/setService.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/acts/setService.ts b/src/acts/setService.ts index 38256ac3..eaee9c1a 100644 --- a/src/acts/setService.ts +++ b/src/acts/setService.ts @@ -8,7 +8,5 @@ import { Acts, Services } from "./types.ts"; export const setService = ( acts: Services, serviceName: keyof typeof acts, - service: Acts | string, -) => { - acts[serviceName] = service; -}; + service: Acts | string +) => (acts[serviceName] = service); From b34ba57c9e1c7151aafe67ca15c31df5cfd6e4c1 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:05:23 +0330 Subject: [PATCH 05/12] tests for getFlattenPureFromRelations are added --- .../getFlattenPureFromRelations.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/models/schema/__tests__/getFlattenPureFromRelations.test.ts diff --git a/src/models/schema/__tests__/getFlattenPureFromRelations.test.ts b/src/models/schema/__tests__/getFlattenPureFromRelations.test.ts new file mode 100644 index 00000000..fd285c0d --- /dev/null +++ b/src/models/schema/__tests__/getFlattenPureFromRelations.test.ts @@ -0,0 +1,39 @@ +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/assert_instance_of.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getFlattenPureFromRelations } from "../getFlattenPureFromRelations.ts"; + +Deno.test({ + name: "getFlattenPureFromRelations should return flatten pureSchemas from mainRelations when MainRelations is passed", + fn() { + const getOneFlattenPureFromRelations = getFlattenPureFromRelations( + schemaMockData, + "city", + "MainRelations" + ); + assertInstanceOf(getOneFlattenPureFromRelations, Object); + }, +}); + +Deno.test({ + name: "getFlattenPureFromRelations should return flatten pureSchemas from relatedRelations when RelatedRelations is passed", + fn() { + const getOneFlattenPureFromRelations = getFlattenPureFromRelations( + schemaMockData, + "city", + "RelatedRelations" + ); + assertInstanceOf(getOneFlattenPureFromRelations, Object); + }, +}); + +Deno.test({ + name: "getFlattenPureFromRelations should return flatten pureSchemas from both relatedRelations and mainRelations when All is passed", + fn() { + const getOneFlattenPureFromRelations = getFlattenPureFromRelations( + schemaMockData, + "city", + "All" + ); + assertInstanceOf(getOneFlattenPureFromRelations, Object); + }, +}); From 3e9fd6d32e306f170d4a509e51cd6d9eabff0232 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:05:55 +0330 Subject: [PATCH 06/12] tests for getPureFromMainRelations are added --- .../__tests__/getPureFromMainRelations.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/models/schema/__tests__/getPureFromMainRelations.test.ts diff --git a/src/models/schema/__tests__/getPureFromMainRelations.test.ts b/src/models/schema/__tests__/getPureFromMainRelations.test.ts new file mode 100644 index 00000000..7b12f4e2 --- /dev/null +++ b/src/models/schema/__tests__/getPureFromMainRelations.test.ts @@ -0,0 +1,14 @@ +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/assert_instance_of.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getPureFromMainRelations } from "../getPureFromMainRelations.ts"; + +Deno.test({ + name: "getPureFromRelatedRelations should return pureSchemas from relatedRelations", + fn() { + const getOnePureFromMainRelations = getPureFromMainRelations( + schemaMockData, + "city" + ); + assertInstanceOf(getOnePureFromMainRelations, Object); + }, +}); From acf842fd9ed253bbe31836bd44116082eb296f51 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:06:32 +0330 Subject: [PATCH 07/12] tests for getPureFromRelatedRelations are added --- .../__tests__/getPureFromRelatedRelations.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/models/schema/__tests__/getPureFromRelatedRelations.test.ts diff --git a/src/models/schema/__tests__/getPureFromRelatedRelations.test.ts b/src/models/schema/__tests__/getPureFromRelatedRelations.test.ts new file mode 100644 index 00000000..2b4396c0 --- /dev/null +++ b/src/models/schema/__tests__/getPureFromRelatedRelations.test.ts @@ -0,0 +1,14 @@ +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/assert_instance_of.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getPureFromRelatedRelations } from "../mod.ts"; + +Deno.test({ + name: "getPureFromRelatedRelations should return pureSchemas from relatedRelations", + fn() { + const getOnePureFromRelatedRelations = getPureFromRelatedRelations( + schemaMockData, + "city" + ); + assertInstanceOf(getOnePureFromRelatedRelations, Object); + }, +}); From c60fb9d257e381d2499adbdd429a701cb917d675 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:07:06 +0330 Subject: [PATCH 08/12] tests for getPureOfMainRelations are added --- .../__tests__/getPureOfMainRelations.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/models/schema/__tests__/getPureOfMainRelations.test.ts diff --git a/src/models/schema/__tests__/getPureOfMainRelations.test.ts b/src/models/schema/__tests__/getPureOfMainRelations.test.ts new file mode 100644 index 00000000..b9b3cc6a --- /dev/null +++ b/src/models/schema/__tests__/getPureOfMainRelations.test.ts @@ -0,0 +1,14 @@ +import { assertInstanceOf } from "https://deno.land/std@0.210.0/assert/assert_instance_of.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getPureOfMainRelations } from "../mod.ts"; + +Deno.test({ + name: "getPureOfMainRelations should return pureSchemas and pureInrel", + fn() { + const getOnePureOfMainRelations = getPureOfMainRelations( + schemaMockData, + "city" + ); + assertInstanceOf(getOnePureOfMainRelations, Object); + }, +}); From ba1e8b6a8ef9f61bc41e45b10c99d872bba6a4df Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:07:31 +0330 Subject: [PATCH 09/12] tests for getPureSchema are added --- .../schema/__tests__/getPureSchema.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/models/schema/__tests__/getPureSchema.test.ts diff --git a/src/models/schema/__tests__/getPureSchema.test.ts b/src/models/schema/__tests__/getPureSchema.test.ts new file mode 100644 index 00000000..e27c88a7 --- /dev/null +++ b/src/models/schema/__tests__/getPureSchema.test.ts @@ -0,0 +1,22 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getPureSchema } from "../getPureSchema.ts"; +import { assertThrows } from "https://deno.land/std@0.210.0/assert/assert_throws.ts"; + +Deno.test({ + name: "getPureSchema should return schema.pure from schemaMockData", + fn() { + assertEquals( + getPureSchema(schemaMockData, "city"), + schemaMockData.city.pure + ); + }, +}); + +Deno.test({ + name: "getPureSchema should throw err when schema does not exist", + fn() { + const getNotSchema = () => getPureSchema(schemaMockData, "notCountry"); + assertThrows(getNotSchema, Error, "Schema notCountry not found"); + }, +}); From be11135da583c9ad7ec2a42fe6b858f85cd8cf09 Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:07:54 +0330 Subject: [PATCH 10/12] tests for getSchema are added --- src/models/schema/__tests__/getSchema.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/models/schema/__tests__/getSchema.test.ts diff --git a/src/models/schema/__tests__/getSchema.test.ts b/src/models/schema/__tests__/getSchema.test.ts new file mode 100644 index 00000000..49269786 --- /dev/null +++ b/src/models/schema/__tests__/getSchema.test.ts @@ -0,0 +1,19 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getSchema } from "../getSchema.ts"; +import { assertThrows } from "https://deno.land/std@0.210.0/assert/assert_throws.ts"; + +Deno.test({ + name: "getSchema should return schemaMockData from schemaMockData", + fn() { + assertEquals(getSchema(schemaMockData, "country"), schemaMockData.country); + }, +}); + +Deno.test({ + name: "getSchema should throw err when schema does not exist", + fn() { + const getNotSchema = () => getSchema(schemaMockData, "notCountry"); + assertThrows(getNotSchema, Error, "Schema notCountry not found"); + }, +}); From cc294d02856ff791c282a7313b77d3d6b737c81f Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:08:20 +0330 Subject: [PATCH 11/12] tests for getSchemasKeys are added --- src/models/schema/__tests__/getSchemaKeys.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/models/schema/__tests__/getSchemaKeys.test.ts diff --git a/src/models/schema/__tests__/getSchemaKeys.test.ts b/src/models/schema/__tests__/getSchemaKeys.test.ts new file mode 100644 index 00000000..cc5bc708 --- /dev/null +++ b/src/models/schema/__tests__/getSchemaKeys.test.ts @@ -0,0 +1,10 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; +import { getSchemasKeys } from "../getSchemaKeys.ts"; + +Deno.test({ + name: "getSchema should return schemaMockData from schemaMockData", + fn() { + assertEquals(getSchemasKeys(schemaMockData), Object.keys(schemaMockData)); + }, +}); From 552970260513775e8bada0ece0ed2cd5a1ae97bd Mon Sep 17 00:00:00 2001 From: MHMoradian Date: Thu, 4 Jan 2024 18:08:46 +0330 Subject: [PATCH 12/12] tests for getSchemas are added --- src/models/schema/__tests__/getSchemas.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/models/schema/__tests__/getSchemas.test.ts diff --git a/src/models/schema/__tests__/getSchemas.test.ts b/src/models/schema/__tests__/getSchemas.test.ts new file mode 100644 index 00000000..1d305c61 --- /dev/null +++ b/src/models/schema/__tests__/getSchemas.test.ts @@ -0,0 +1,10 @@ +import { assertEquals } from "https://deno.land/std@0.210.0/assert/assert_equals.ts"; +import { getSchemas } from "../getSchemas.ts"; +import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; + +Deno.test({ + name: "getSchemas should return schemaMockData from schemaMockData", + fn() { + assertEquals(getSchemas(schemaMockData), schemaMockData); + }, +});