-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: code generation for int64 map values in fromPartial and fromJson (…
…#395) * fix code generation for int64 map values in fromPartial and fromJson * Add tests and some follow up fixes. * Fix test. Co-authored-by: christians <christian.schroeder@consistec.de> Co-authored-by: Stephen Haberman <stephen.haberman@gmail.com>
- Loading branch information
1 parent
81d58b0
commit d3ea8eb
Showing
12 changed files
with
319 additions
and
61 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { SimpleWithMap } from './simple'; | ||
|
||
describe('simple', () => { | ||
it('can fromPartial maps', () => { | ||
const s1 = SimpleWithMap.fromPartial({ | ||
intLookup: { 1: 2, 2: 1 }, | ||
longLookup: { '1': 2, '2': 1 }, | ||
}); | ||
expect(s1).toMatchInlineSnapshot(` | ||
Object { | ||
"intLookup": Object { | ||
"1": 2, | ||
"2": 1, | ||
}, | ||
"longLookup": Object { | ||
"1": Long { | ||
"high": 0, | ||
"low": 2, | ||
"unsigned": false, | ||
}, | ||
"2": Long { | ||
"high": 0, | ||
"low": 1, | ||
"unsigned": false, | ||
}, | ||
}, | ||
"nameLookup": Object {}, | ||
} | ||
`); | ||
}); | ||
|
||
it('can toJSON/fromJSON maps', () => { | ||
const s1 = SimpleWithMap.fromPartial({ | ||
intLookup: { 1: 2, 2: 1 }, | ||
longLookup: { '1': 2, '2': 1 }, | ||
}); | ||
|
||
const json = SimpleWithMap.toJSON(s1); | ||
expect(json).toMatchInlineSnapshot(` | ||
Object { | ||
"intLookup": Object { | ||
"1": 2, | ||
"2": 1, | ||
}, | ||
"longLookup": Object { | ||
"1": "2", | ||
"2": "1", | ||
}, | ||
"nameLookup": Object {}, | ||
} | ||
`); | ||
|
||
const s2 = SimpleWithMap.fromJSON(JSON.parse(JSON.stringify(json))); | ||
expect(s2).toMatchInlineSnapshot(` | ||
Object { | ||
"intLookup": Object { | ||
"1": 2, | ||
"2": 1, | ||
}, | ||
"longLookup": Object { | ||
"1": Long { | ||
"high": 0, | ||
"low": 2, | ||
"unsigned": false, | ||
}, | ||
"2": Long { | ||
"high": 0, | ||
"low": 1, | ||
"unsigned": false, | ||
}, | ||
}, | ||
"nameLookup": Object {}, | ||
} | ||
`); | ||
}); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.