Skip to content

Commit

Permalink
test BigInt if supported by the env
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusTheHun committed Feb 27, 2021
1 parent 65c650f commit a1bc322
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,18 @@ const tests = ({ stringify, parse }) => {
expect(parsed).toMatchObject(data);
});

test('check BigInt value', () => {
const data = { LotOfFruits: BigInt("123456789123456789123456789123456789") };
// BigInt only comes with Node > 10.4.0
if ('BigInt' in global) {
test('check BigInt value', () => {
const data = { LotOfFruits: BigInt("123456789123456789123456789123456789") };

const stringified = stringify(data);
const parsed = parse(stringified);
const stringified = stringify(data);
const parsed = parse(stringified);

expect(stringified).toEqual('{"LotOfFruits":"_bigint_123456789123456789123456789123456789"}');
expect(parsed).toMatchObject(data);
});
expect(stringified).toEqual('{"LotOfFruits":"_bigint_123456789123456789123456789123456789"}');
expect(parsed).toMatchObject(data);
});
}

test('check undefined value', () => {
const data = { undefinedFruit: undefined };
Expand Down

0 comments on commit a1bc322

Please sign in to comment.