From 6f95fd20aba8e74eed9cfeb2c354e207645f3714 Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Thu, 13 Jul 2023 16:34:00 +0100 Subject: [PATCH] Fix tests --- integration/simple-long/simple-test.ts | 1 - integration/simple/simple-json-test.ts | 37 +------------------ .../use-numeric-enum-json/simple-test.ts | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/integration/simple-long/simple-test.ts b/integration/simple-long/simple-test.ts index e3bb31bb2..5842c90af 100644 --- a/integration/simple-long/simple-test.ts +++ b/integration/simple-long/simple-test.ts @@ -73,7 +73,6 @@ describe("simple", () => { "1": "2", "2": "1", }, - "nameLookup": {}, } `); diff --git a/integration/simple/simple-json-test.ts b/integration/simple/simple-json-test.ts index c15e8d10e..f7a114591 100644 --- a/integration/simple/simple-json-test.ts +++ b/integration/simple/simple-json-test.ts @@ -247,16 +247,10 @@ describe("simple json", () => { const json = SimpleWithMap.toJSON(s1); expect(json).toMatchInlineSnapshot(` { - "entitiesById": {}, - "intLookup": {}, - "longLookup": {}, "mapOfBytes": { "a": "AQI=", "b": "AQID", }, - "mapOfStringValues": {}, - "mapOfTimestamps": {}, - "nameLookup": {}, } `); }); @@ -315,11 +309,8 @@ describe("simple json", () => { expect(Simple.toJSON(s1)).toMatchInlineSnapshot(` { "age": 1, - "blob": "", - "blobs": [], "child": { "name": "foo", - "type": "UNKNOWN", }, "coins": [ 2, @@ -331,11 +322,9 @@ describe("simple json", () => { "grandChildren": [ { "name": "grand1", - "type": "UNKNOWN", }, { "name": "grand2", - "type": "UNKNOWN", }, ], "name": "asdf", @@ -352,32 +341,15 @@ describe("simple json", () => { `); }); - it("can encode empty objects", () => { - expect(Simple.toJSON({} as Simple)).toMatchInlineSnapshot(` - { - "blobs": [], - "coins": [], - "grandChildren": [], - "oldStates": [], - "snacks": [], - } - `); - }); - it("can encode nested enums", () => { - const s1 = { child: { name: "a", type: Child_Type.GOOD } } as Simple; + const s1 = Simple.fromPartial({ child: { name: "a", type: Child_Type.GOOD } }); const s2 = Simple.toJSON(s1); expect(s2).toMatchInlineSnapshot(` { - "blobs": [], "child": { "name": "a", "type": "GOOD", }, - "coins": [], - "grandChildren": [], - "oldStates": [], - "snacks": [], } `); }); @@ -425,12 +397,7 @@ describe("simple json", () => { id: undefined, }; const s2 = SimpleWithWrappers.toJSON(s1); - expect(s2).toMatchInlineSnapshot(` - { - "coins": [], - "snacks": [], - } - `); + expect(s2).toMatchInlineSnapshot(`{}`); }); it("can decode enum falsey values", () => { diff --git a/integration/use-numeric-enum-json/simple-test.ts b/integration/use-numeric-enum-json/simple-test.ts index a5a0dbf74..92edb7b3f 100644 --- a/integration/use-numeric-enum-json/simple-test.ts +++ b/integration/use-numeric-enum-json/simple-test.ts @@ -14,7 +14,7 @@ describe('use-numeric-enum-json', () => { const json = Simple.toJSON(s); // Make sure that enum values are encoded as integers. - expect(json).toEqual({ name: 'a', nullValue: 0, state: 2, stateMap: { on: 2 }, states: [2, 3] }); + expect(json).toEqual({ name: 'a', state: 2, stateMap: { on: 2 }, states: [2, 3] }); // Original object can be recovered from the json. expect(Simple.fromJSON(json)).toEqual(s);