Skip to content

Commit

Permalink
chore: use number constants in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Aug 26, 2021
1 parent 40915e3 commit 3846251
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions packages/smithy-client/src/parse-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,19 @@ describe("expectFloat32", () => {

describe("expectLong", () => {
describe("accepts 64-bit integers", () => {
it.each([1, 2 ** 63 - 1, -(2 ** 63), 2 ** 31 - 1, -(2 ** 31), 2 ** 15 - 1, -(2 ** 15), 127, -128])(
"accepts %s",
(value) => {
expect(expectLong(value)).toEqual(value);
}
);
it.each([
1,
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
2 ** 31 - 1,
-(2 ** 31),
2 ** 15 - 1,
-(2 ** 15),
127,
-128,
])("accepts %s", (value) => {
expect(expectLong(value)).toEqual(value);
});
});

it.each([null, undefined])("accepts %s", (value) => {
Expand All @@ -172,12 +179,21 @@ describe("expectInt32", () => {
});

describe("rejects non-integers", () => {
it.each([1.1, "1", "1.1", NaN, true, [], {}, 2 ** 63 - 1, -(2 ** 63 + 1), 2 ** 31, -(2 ** 31 + 1)])(
"rejects %s",
(value) => {
expect(() => expectInt32(value)).toThrowError();
}
);
it.each([
1.1,
"1",
"1.1",
NaN,
true,
[],
{},
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
2 ** 31,
-(2 ** 31 + 1),
])("rejects %s", (value) => {
expect(() => expectInt32(value)).toThrowError();
});
});
});

Expand Down Expand Up @@ -233,8 +249,8 @@ describe("expectByte", () => {
true,
[],
{},
2 ** 63 - 1,
-(2 ** 63 + 1),
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
2 ** 31 - 1,
-(2 ** 31 + 1),
2 ** 15 - 1,
Expand Down

0 comments on commit 3846251

Please sign in to comment.