diff --git a/src/tests/modifiers/common.test.ts b/src/tests/modifiers/common.test.ts index 920b5a9..0ffa8ab 100644 --- a/src/tests/modifiers/common.test.ts +++ b/src/tests/modifiers/common.test.ts @@ -8,7 +8,7 @@ import { TwoWayModifier, toDatabase, } from "@antelopejs/interface-database-decorators/modifiers/common"; -import { Table } from "@antelopejs/interface-database-decorators/table"; +import { Field, Table } from "@antelopejs/interface-database-decorators/table"; import { expect } from "chai"; describe("Modifiers - common", () => { @@ -108,6 +108,7 @@ async function AttachWithOptionsTest() { } } class TestTable extends Table { + @Field("string") declare name: string; } @@ -135,6 +136,7 @@ async function ChainedModifiersTest() { } class TestTable extends Table { + @Field("string") name!: string; } @@ -158,6 +160,7 @@ async function DuplicateOneWayErrorTest() { } class TestTable extends Table { + @Field("string") name!: string; } @@ -169,7 +172,9 @@ async function DuplicateOneWayErrorTest() { async function ConvertDatabaseDataToTableTest() { class TestTable extends Table { + @Field("string") name!: string; + @Field("number") age!: number; } @@ -183,7 +188,9 @@ async function ConvertDatabaseDataToTableTest() { async function ConvertTableToDatabaseDataTest() { class TestTable extends Table { + @Field("string") name!: string; + @Field("number") age!: number; } @@ -204,7 +211,9 @@ async function GetModifiedFieldsTest() { } class TestTable extends Table { + @Field("string") name!: string; + @Field("number") age!: number; } diff --git a/src/tests/modifiers/encryption.test.ts b/src/tests/modifiers/encryption.test.ts index ecf76f8..4a6cb73 100644 --- a/src/tests/modifiers/encryption.test.ts +++ b/src/tests/modifiers/encryption.test.ts @@ -2,7 +2,7 @@ import { Encrypted, EncryptionModifier, } from "@antelopejs/interface-database-decorators/modifiers/encryption"; -import { Table } from "@antelopejs/interface-database-decorators/table"; +import { Field, Table } from "@antelopejs/interface-database-decorators/table"; import { expect } from "chai"; describe("Modifiers - encryption", () => { @@ -25,6 +25,7 @@ async function CreateEncryptionModifierTest() { const Mixed = Table.with(EncryptionModifier); class Sample extends Mixed { @Encrypted({ secretKey: "12345678901234567890123456789012" }) + @Field("string") declare value: string; } @@ -39,6 +40,7 @@ async function EncryptAndDecryptStringValuesTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("string") declare email: string; } @@ -53,6 +55,7 @@ async function EncryptAndDecryptObjectValuesTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("any") declare meta: Record; } @@ -68,6 +71,7 @@ async function EncryptAndDecryptArrayValuesTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("any") declare values: (string | { deep: string })[]; } @@ -84,6 +88,7 @@ async function UseCustomIvSizeTest() { ivSize: 16, algorithm: "aes-256-cbc", }) + @Field("string") declare data: string; } @@ -98,12 +103,14 @@ async function HandleEncryptionDecoratorTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("string") declare password: string; @Encrypted({ secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("any") declare extra: Record; } @@ -121,6 +128,7 @@ async function GenerateUniqueIvForEachEncryptionTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("string") declare body: string; } const m1 = new Message(); @@ -140,6 +148,7 @@ async function PreserveDataIntegrityTest() { secretKey: "12345678901234567890123456789012", algorithm: "aes-256-cbc", }) + @Field("any") declare payload: { string: string; number: number; diff --git a/src/tests/modifiers/hash.test.ts b/src/tests/modifiers/hash.test.ts index a8ee340..c08840e 100644 --- a/src/tests/modifiers/hash.test.ts +++ b/src/tests/modifiers/hash.test.ts @@ -2,7 +2,7 @@ import { Hashed, HashModifier, } from "@antelopejs/interface-database-decorators/modifiers/hash"; -import { Table } from "@antelopejs/interface-database-decorators/table"; +import { Field, Table } from "@antelopejs/interface-database-decorators/table"; import { expect } from "chai"; describe("Modifiers - hash", () => { @@ -112,6 +112,7 @@ async function GenerateUniqueSaltForEachFieldTest() { async function HandleHashDecoratorTest() { class TestTable extends Table.with(HashModifier) { @Hashed({ algorithm: "sha256" }) + @Field("string") declare password: string; } @@ -140,6 +141,7 @@ async function TestHashValuesTest() { async function ProvideTestHashMethodTest() { class TestTable extends Table.with(HashModifier) { @Hashed({ algorithm: "sha256" }) + @Field("string") declare password: string; } diff --git a/src/tests/modifiers/localization.test.ts b/src/tests/modifiers/localization.test.ts index b6589f9..5791bc0 100644 --- a/src/tests/modifiers/localization.test.ts +++ b/src/tests/modifiers/localization.test.ts @@ -2,7 +2,7 @@ import { LocalizationModifier, Localized, } from "@antelopejs/interface-database-decorators/modifiers/localization"; -import { Table } from "@antelopejs/interface-database-decorators/table"; +import { Field, Table } from "@antelopejs/interface-database-decorators/table"; import { expect } from "chai"; describe("Modifiers - localization", () => { @@ -116,9 +116,11 @@ async function ProvideLocalizeMethodTest() { class TestTable extends TestTableWithMixin { @Localized({ fallbackLocale: "en" }) + @Field("string") declare title: string; @Localized({ fallbackLocale: "en" }) + @Field("string") declare description: string; } @@ -131,9 +133,11 @@ async function ProvideLocalizeMethodTest() { async function HandleLocalizationDecoratorTest() { class TestTable extends Table.with(LocalizationModifier) { @Localized({ fallbackLocale: "en" }) + @Field("string") declare title: string; @Localized({ fallbackLocale: "fr" }) + @Field("string") declare description: string; } @@ -155,12 +159,15 @@ async function LocalizeSpecificFieldsTest() { class TestTable extends TestTableWithMixin { @Localized({ fallbackLocale: "en" }) + @Field("string") declare title: string; @Localized({ fallbackLocale: "en" }) + @Field("string") declare description: string; @Localized({ fallbackLocale: "en" }) + @Field("string") declare content: string; } diff --git a/src/tests/schema.test.ts b/src/tests/schema.test.ts index 53fce4e..96614e2 100644 --- a/src/tests/schema.test.ts +++ b/src/tests/schema.test.ts @@ -6,7 +6,11 @@ import { getTablesForSchema, RegisterTable, } from "@antelopejs/interface-database-decorators/schema"; -import { Index, Table } from "@antelopejs/interface-database-decorators/table"; +import { + Field, + Index, + Table, +} from "@antelopejs/interface-database-decorators/table"; import { expect } from "chai"; describe("Schema - RegisterTable decorator", () => { @@ -24,6 +28,7 @@ describe("Schema - RegisterTable decorator", () => { async function StoreTableNameAndSchemaNameInMetadataTest() { @RegisterTable("test_table", "test-schema") class TestTable extends Table { + @Field("string") name!: string; } @@ -36,16 +41,20 @@ async function StoreTableNameForMultipleClassesTest() { @RegisterTable("user_table", "multi-schema") class UserTable extends Table { @Index() + @Field("string") email!: string; + @Field("string") name!: string; } @RegisterTable("product_table", "multi-schema") class ProductTable extends Table { @Index() + @Field("string") name!: string; + @Field("number") price!: number; } @@ -62,8 +71,10 @@ async function PreserveExistingMetadataTest() { @RegisterTable("indexed_table", "preserve-schema") class IndexedTable extends Table { @Index() + @Field("string") email!: string; + @Field("string") name!: string; }