Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested unmanaged types #6943

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add mixed type tests
  • Loading branch information
liamjones committed Dec 9, 2024
commit e8a53fd5704e669073e995e5bf567d9aa521fcc1
13 changes: 13 additions & 0 deletions packages/realm/type-tests/nested-unmanaged-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class RealmClassWithRequiredParams extends Realm.Object<
| "aMandatoryObjectId"
| "aMandatoryData"
| "aMandatoryDate"
| "aMandatoryMixed"
> {
public aMandatoryString!: Realm.Types.String;
public anOptionalString?: Realm.Types.String;
Expand All @@ -46,6 +47,7 @@ class RealmClassWithRequiredParams extends Realm.Object<
public aMandatoryObjectId!: Realm.Types.ObjectId;
public aMandatoryData!: Realm.Types.Data;
public aMandatoryDate!: Realm.Types.Date;
public aMandatoryMixed!: Realm.Types.Mixed;

static schema: Realm.ObjectSchema = {
name: "RealmClassWithRequiredParams",
Expand All @@ -60,6 +62,11 @@ class RealmClassWithRequiredParams extends Realm.Object<
aMandatoryObjectId: "objectId",
aMandatoryData: "data",
aMandatoryDate: "date",
// TODO list
// TODO linkingObjects?
// TODO dictionary
// TODO set
aMandatoryMixed: "mixed",
},
};

Expand All @@ -79,6 +86,7 @@ class RealmClassWithoutRequiredParams extends Realm.Object<RealmClassWithoutRequ
public aMandatoryObjectId!: Realm.Types.ObjectId;
public aMandatoryData!: Realm.Types.Data;
public aMandatoryDate!: Realm.Types.Date;
public aMandatoryMixed!: Realm.Types.Mixed;

static schema: Realm.ObjectSchema = {
name: "RealmClassWithoutRequiredParams",
Expand All @@ -93,6 +101,7 @@ class RealmClassWithoutRequiredParams extends Realm.Object<RealmClassWithoutRequ
aMandatoryObjectId: "objectId",
aMandatoryData: "data",
aMandatoryDate: "date",
aMandatoryMixed: "mixed",
},
};

Expand Down Expand Up @@ -128,6 +137,7 @@ realm.write(() => {
aMandatoryObjectId: new BSON.ObjectId(123),
aMandatoryData: new ArrayBuffer(123),
aMandatoryDate: new Date(),
aMandatoryMixed: "a",
}),
);

Expand All @@ -149,6 +159,7 @@ realm.write(() => {
aMandatoryObjectId: new BSON.ObjectId(123),
aMandatoryData: new ArrayBuffer(123),
aMandatoryDate: new Date(),
aMandatoryMixed: 1,
});

realm.create(RealmClassWithoutRequiredParams, {});
Expand All @@ -169,6 +180,7 @@ const realmObjectPropertiesOmitted2: Realm.Unmanaged<
| "aMandatoryObjectId"
| "aMandatoryData"
| "aMandatoryDate"
| "aMandatoryMixed"
> = {
aMandatoryString: "string",
aMandatoryBool: true,
Expand All @@ -179,4 +191,5 @@ const realmObjectPropertiesOmitted2: Realm.Unmanaged<
aMandatoryObjectId: new BSON.ObjectId(123),
aMandatoryData: new ArrayBuffer(123),
aMandatoryDate: new Date(),
aMandatoryMixed: true,
};