Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haines committed Jul 13, 2023
1 parent bb6e0a9 commit 6f95fd2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
1 change: 0 additions & 1 deletion integration/simple-long/simple-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ describe("simple", () => {
"1": "2",
"2": "1",
},
"nameLookup": {},
}
`);

Expand Down
37 changes: 2 additions & 35 deletions integration/simple/simple-json-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
}
`);
});
Expand Down Expand Up @@ -315,11 +309,8 @@ describe("simple json", () => {
expect(Simple.toJSON(s1)).toMatchInlineSnapshot(`
{
"age": 1,
"blob": "",
"blobs": [],
"child": {
"name": "foo",
"type": "UNKNOWN",
},
"coins": [
2,
Expand All @@ -331,11 +322,9 @@ describe("simple json", () => {
"grandChildren": [
{
"name": "grand1",
"type": "UNKNOWN",
},
{
"name": "grand2",
"type": "UNKNOWN",
},
],
"name": "asdf",
Expand All @@ -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": [],
}
`);
});
Expand Down Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/use-numeric-enum-json/simple-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f95fd2

Please sign in to comment.