Skip to content

Commit

Permalink
feat: Refactor test cases to use native node.js test suite api
Browse files Browse the repository at this point in the history
  • Loading branch information
moraesjeremias committed Aug 7, 2024
1 parent f5a771e commit 41e4b27
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/tests/parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import assert from "assert/strict";
import { describe, it } from "node:test";
import { BigNumber } from "bignumber.js";
import parseAmount from "../helpers/parser.js";

function testNormalBigAmount() {
const rawFungibleTokenAmount = "0x00000000000000000de0b6b3a7640000";
const bigNumberString = BigNumber(rawFungibleTokenAmount, 16).toFixed(0);
const amountPrettified = parseAmount(bigNumberString);
const expectedParsedAmount = "1.0";
assert.deepStrictEqual(amountPrettified, expectedParsedAmount);
}
describe("Test tx amount parse", () => {
it("Should parse rawFungibleTokenAmount on 18 digit BigNumber value", () => {
const rawFungibleTokenAmount = "0x00000000000000000de0b6b3a7640000";
const bigNumberString = BigNumber(rawFungibleTokenAmount, 16).toFixed(0);
const amountPrettified = parseAmount(bigNumberString);
const expectedParsedAmount = "1.0";
assert.deepStrictEqual(amountPrettified, expectedParsedAmount);
});

function testScientificBigAmount() {
const rawFungibleTokenAmount = "0x000000000000182a697403a1b0cf0ad2";
const bigNumberString = BigNumber(rawFungibleTokenAmount, 16).toFixed(0);
const amountPrettified = parseAmount(bigNumberString);
const expectedParsedAmount = "114119.157542431558142674";
assert.deepStrictEqual(amountPrettified, expectedParsedAmount);
}

testNormalBigAmount();
testScientificBigAmount();
it("Should parse rawFungibleTokenAmount on 24 digit scientific BigNumber value", () => {
const rawFungibleTokenAmount = "0x000000000000182a697403a1b0cf0ad2";
const bigNumberString = BigNumber(rawFungibleTokenAmount, 16).toFixed(0);
const amountPrettified = parseAmount(bigNumberString);
const expectedParsedAmount = "114119.157542431558142674";
assert.deepStrictEqual(amountPrettified, expectedParsedAmount);
});
});

0 comments on commit 41e4b27

Please sign in to comment.