From 430a76aef4fd7b11b0519f8f23a8cfbb9417eb06 Mon Sep 17 00:00:00 2001 From: LJ <81748770+elle-j@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:48:12 +0200 Subject: [PATCH] Test that property values are correctly updated. --- integration-tests/tests/src/tests/objects.ts | 45 +++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/integration-tests/tests/src/tests/objects.ts b/integration-tests/tests/src/tests/objects.ts index d12c33df87..61a10e2efc 100644 --- a/integration-tests/tests/src/tests/objects.ts +++ b/integration-tests/tests/src/tests/objects.ts @@ -639,8 +639,8 @@ describe("Realm.Object", () => { }); it("can be updated recursively in lists", function (this: Mocha.Context & RealmContext) { - this.realm.write(() => { - this.realm.create( + const alice = this.realm.write(() => { + return this.realm.create( CollectionSchema.name, { _id: aliceId, @@ -661,11 +661,22 @@ describe("Realm.Object", () => { Realm.UpdateMode.All, ); }); + + expect(alice._id.equals(aliceId)).to.be.true; + expect(alice.name).to.equal("UpdatedAlice"); + + const bob = alice.list[0]; + expect(bob._id.equals(bobId)).to.be.true; + expect(bob.name).to.equal("UpdatedBob"); + + const max = bob.list[0]; + expect(max._id.equals(maxId)).to.be.true; + expect(max.name).to.equal("UpdatedMax"); }); it("can be updated recursively in dictionaries", function (this: Mocha.Context & RealmContext) { - this.realm.write(() => { - this.realm.create( + const alice = this.realm.write(() => { + return this.realm.create( CollectionSchema.name, { _id: aliceId, @@ -686,11 +697,22 @@ describe("Realm.Object", () => { Realm.UpdateMode.All, ); }); + + expect(alice._id.equals(aliceId)).to.be.true; + expect(alice.name).to.equal("UpdatedAlice"); + + const { bob } = alice.dictionary; + expect(bob._id.equals(bobId)).to.be.true; + expect(bob.name).to.equal("UpdatedBob"); + + const { max } = bob.dictionary; + expect(max._id.equals(maxId)).to.be.true; + expect(max.name).to.equal("UpdatedMax"); }); it("can be updated recursively in sets", function (this: Mocha.Context & RealmContext) { - this.realm.write(() => { - this.realm.create( + const alice = this.realm.write(() => { + return this.realm.create( CollectionSchema.name, { _id: aliceId, @@ -711,6 +733,17 @@ describe("Realm.Object", () => { Realm.UpdateMode.All, ); }); + + expect(alice._id.equals(aliceId)).to.be.true; + expect(alice.name).to.equal("UpdatedAlice"); + + const bob = alice.set[0]; + expect(bob._id.equals(bobId)).to.be.true; + expect(bob.name).to.equal("UpdatedBob"); + + const max = bob.set[0]; + expect(max._id.equals(maxId)).to.be.true; + expect(max.name).to.equal("UpdatedMax"); }); }); });