-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib-dynamodb): large number handling, remove extra unmarshall op…
…tion
- Loading branch information
Showing
12 changed files
with
120 additions
and
205 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import { NumberValue } from "./NumberValue"; | ||
|
||
const BIG_DECIMAL = | ||
"123456789012345678901234567890123456789012345678901234567890.123456789012345678901234567890123456789012345678901234567890"; | ||
const BIG_INT = "123456789012345678901234567890123456789012345678901234567890"; | ||
|
||
describe(NumberValue.name, () => { | ||
it("can be statically constructed from numbers", () => { | ||
expect(NumberValue.from(123.123).toString()).toEqual("123.123"); | ||
|
||
expect(() => NumberValue.from(1.23e100)).toThrow(); | ||
expect(() => NumberValue.from(Infinity)).toThrow(); | ||
expect(() => NumberValue.from(-Infinity)).toThrow(); | ||
expect(() => NumberValue.from(NaN)).toThrow(); | ||
}); | ||
|
||
it("can be statically constructed from strings", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toString()).toEqual(BIG_DECIMAL); | ||
}); | ||
|
||
it("can be statically constructed from BigInts", () => { | ||
expect(NumberValue.from(BigInt(BIG_INT)).toString()).toEqual(BIG_INT); | ||
}); | ||
|
||
it("can convert to AttributeValue", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toAttributeValue()).toEqual({ | ||
N: BIG_DECIMAL, | ||
}); | ||
}); | ||
|
||
it("can convert to string", () => { | ||
expect(NumberValue.from(BIG_DECIMAL).toString()).toEqual(BIG_DECIMAL); | ||
}); | ||
|
||
it("can convert to BigInt", () => { | ||
expect(NumberValue.from(BIG_INT).toBigInt()).toEqual(BigInt(BIG_INT)); | ||
}); | ||
}); |
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.