Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Duncalf committed Jan 6, 2022
1 parent 43c60ca commit d7e583e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
7 changes: 2 additions & 5 deletions integration-tests/tests/src/hooks/open-realm-before.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ export function openRealmHook(config: LocalConfiguration | SyncedConfiguration =
};
}

export function closeRealm(this: RealmContext): void {
export function closeRealm(this: Partial<RealmContext> & Mocha.Context): void {
if (this.realm) {
this.realm.close();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Ignore error as we ensure the realm is reopened
delete this.realm;
} else {
throw new Error("Expected a 'realm' in the context");
}

if (this.config) {
Realm.deleteFile(this.config);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Ignore error as we ensure the config is recreated
delete this.config;
} else {
throw new Error("Expected a 'config' in the context");
Expand Down
25 changes: 10 additions & 15 deletions integration-tests/tests/src/tests/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ describe("Realm objects", () => {
describe("Interface & object literal", () => {
it("can be created", () => {
const realm = new Realm({ schema: [PersonSchema] });
let john!: IPerson;

realm.write(() => {
john = realm.create<IPerson>(PersonSchema.name, {
const john = realm.write(() => {
return realm.create<IPerson>(PersonSchema.name, {
name: "John Doe",
age: 42,
});
Expand All @@ -51,10 +50,9 @@ describe("Realm objects", () => {

it("can have it's properties read", () => {
const realm = new Realm({ schema: [PersonSchema] });
let john!: IPerson;

realm.write(() => {
john = realm.create<IPerson>(PersonSchema.name, {
const john = realm.write(() => {
return realm.create<IPerson>(PersonSchema.name, {
name: "John Doe",
age: 42,
});
Expand Down Expand Up @@ -87,11 +85,10 @@ describe("Realm objects", () => {

it("can be updated", () => {
const realm = new Realm({ schema: [PersonSchemaWithId] });
let john!: IPersonWithId;
const _id = new Realm.BSON.ObjectId();

realm.write(() => {
john = realm.create<IPersonWithId>(PersonSchemaWithId.name, {
const john = realm.write(() => {
return realm.create<IPersonWithId>(PersonSchemaWithId.name, {
_id,
name: "John Doe",
age: 42,
Expand Down Expand Up @@ -161,10 +158,9 @@ describe("Realm objects", () => {
describe("Class Model", () => {
it("can be created", () => {
const realm = new Realm({ schema: [Person] });
let john!: Person;

realm.write(() => {
john = realm.create(Person, {
const john = realm.write(() => {
return realm.create(Person, {
name: "John Doe",
age: 42,
});
Expand Down Expand Up @@ -213,11 +209,10 @@ describe("Realm objects", () => {

it("can be updated", () => {
const realm = new Realm({ schema: [PersonWithId] });
let john!: PersonWithId;
const _id = new Realm.BSON.ObjectId();

realm.write(() => {
john = realm.create(PersonWithId, {
const john = realm.write(() => {
return realm.create(PersonWithId, {
_id,
name: "John Doe",
age: 42,
Expand Down

0 comments on commit d7e583e

Please sign in to comment.