-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from MHMoradian/main
tests for schemas are added (plus some minor bugs fixed)
- Loading branch information
Showing
12 changed files
with
174 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/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/[email protected]/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); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/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/[email protected]/assert/mod.ts"; | ||
|
||
Deno.test({ | ||
name: "getPureSchema should return schema.pure from schemaMockData", | ||
fn() { | ||
assertInstanceOf(createStruct(schemaMockData, "city"), Object); | ||
}, | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/models/schema/__tests__/getFlattenPureFromRelations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { assertInstanceOf } from "https://deno.land/[email protected]/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); | ||
}, | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/models/schema/__tests__/getPureFromMainRelations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { assertInstanceOf } from "https://deno.land/[email protected]/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); | ||
}, | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/models/schema/__tests__/getPureFromRelatedRelations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { assertInstanceOf } from "https://deno.land/[email protected]/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); | ||
}, | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/models/schema/__tests__/getPureOfMainRelations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { assertInstanceOf } from "https://deno.land/[email protected]/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); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts"; | ||
import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; | ||
import { getPureSchema } from "../getPureSchema.ts"; | ||
import { assertThrows } from "https://deno.land/[email protected]/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"); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts"; | ||
import { schemaMockData } from "../../mainRelations/__test__/getMainRelations.test.ts"; | ||
import { getSchema } from "../getSchema.ts"; | ||
import { assertThrows } from "https://deno.land/[email protected]/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"); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/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)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/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); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters