-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor test cases to use native node.js test suite api
- Loading branch information
1 parent
f5a771e
commit 41e4b27
Showing
1 changed file
with
17 additions
and
17 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
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); | ||
}); | ||
}); |