Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/tests/modifiers/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -108,6 +108,7 @@ async function AttachWithOptionsTest() {
}
}
class TestTable extends Table {
@Field("string")
declare name: string;
}

Expand Down Expand Up @@ -135,6 +136,7 @@ async function ChainedModifiersTest() {
}

class TestTable extends Table {
@Field("string")
name!: string;
}

Expand All @@ -158,6 +160,7 @@ async function DuplicateOneWayErrorTest() {
}

class TestTable extends Table {
@Field("string")
name!: string;
}

Expand All @@ -169,7 +172,9 @@ async function DuplicateOneWayErrorTest() {

async function ConvertDatabaseDataToTableTest() {
class TestTable extends Table {
@Field("string")
name!: string;
@Field("number")
age!: number;
}

Expand All @@ -183,7 +188,9 @@ async function ConvertDatabaseDataToTableTest() {

async function ConvertTableToDatabaseDataTest() {
class TestTable extends Table {
@Field("string")
name!: string;
@Field("number")
age!: number;
}

Expand All @@ -204,7 +211,9 @@ async function GetModifiedFieldsTest() {
}

class TestTable extends Table {
@Field("string")
name!: string;
@Field("number")
age!: number;
}

Expand Down
11 changes: 10 additions & 1 deletion src/tests/modifiers/encryption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -25,6 +25,7 @@ async function CreateEncryptionModifierTest() {
const Mixed = Table.with(EncryptionModifier);
class Sample extends Mixed {
@Encrypted({ secretKey: "12345678901234567890123456789012" })
@Field("string")
declare value: string;
}

Expand All @@ -39,6 +40,7 @@ async function EncryptAndDecryptStringValuesTest() {
secretKey: "12345678901234567890123456789012",
algorithm: "aes-256-cbc",
})
@Field("string")
declare email: string;
}

Expand All @@ -53,6 +55,7 @@ async function EncryptAndDecryptObjectValuesTest() {
secretKey: "12345678901234567890123456789012",
algorithm: "aes-256-cbc",
})
@Field("any")
declare meta: Record<string, unknown>;
}

Expand All @@ -68,6 +71,7 @@ async function EncryptAndDecryptArrayValuesTest() {
secretKey: "12345678901234567890123456789012",
algorithm: "aes-256-cbc",
})
@Field("any")
declare values: (string | { deep: string })[];
}

Expand All @@ -84,6 +88,7 @@ async function UseCustomIvSizeTest() {
ivSize: 16,
algorithm: "aes-256-cbc",
})
@Field("string")
declare data: string;
}

Expand All @@ -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<string, unknown>;
}

Expand All @@ -121,6 +128,7 @@ async function GenerateUniqueIvForEachEncryptionTest() {
secretKey: "12345678901234567890123456789012",
algorithm: "aes-256-cbc",
})
@Field("string")
declare body: string;
}
const m1 = new Message();
Expand All @@ -140,6 +148,7 @@ async function PreserveDataIntegrityTest() {
secretKey: "12345678901234567890123456789012",
algorithm: "aes-256-cbc",
})
@Field("any")
declare payload: {
string: string;
number: number;
Expand Down
4 changes: 3 additions & 1 deletion src/tests/modifiers/hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -112,6 +112,7 @@ async function GenerateUniqueSaltForEachFieldTest() {
async function HandleHashDecoratorTest() {
class TestTable extends Table.with(HashModifier) {
@Hashed({ algorithm: "sha256" })
@Field("string")
declare password: string;
}

Expand Down Expand Up @@ -140,6 +141,7 @@ async function TestHashValuesTest() {
async function ProvideTestHashMethodTest() {
class TestTable extends Table.with(HashModifier) {
@Hashed({ algorithm: "sha256" })
@Field("string")
declare password: string;
}

Expand Down
9 changes: 8 additions & 1 deletion src/tests/modifiers/localization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
13 changes: 12 additions & 1 deletion src/tests/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -24,6 +28,7 @@ describe("Schema - RegisterTable decorator", () => {
async function StoreTableNameAndSchemaNameInMetadataTest() {
@RegisterTable("test_table", "test-schema")
class TestTable extends Table {
@Field("string")
name!: string;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
Loading