-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuzuswapteam004
committed
Sep 16, 2024
1 parent
2c865c4
commit f86f3c7
Showing
1 changed file
with
28 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { planckToTokens } from "./planckToTokens" | ||
|
||
describe("planckToTokens", () => { | ||
it("should correctly convert planck to tokens with given decimals", () => { | ||
expect(planckToTokens("1000000", 6)).toBe("1") | ||
expect(planckToTokens("123456789", 8)).toBe("1.23456789") | ||
}) | ||
|
||
it("should return undefined if planck is not a string", () => { | ||
expect(planckToTokens(1000000000 as unknown as string, 18)).toBeUndefined() | ||
}) | ||
|
||
it("should return undefined if tokenDecimals is not a number", () => { | ||
expect(planckToTokens("1000000000", "18" as unknown as number)).toBeUndefined() | ||
}) | ||
|
||
it("should handle missing tokenDecimals", () => { | ||
expect(planckToTokens("1000000000")).toBeUndefined() | ||
}) | ||
|
||
it("should handle missing planck", () => { | ||
expect(planckToTokens(undefined, 18)).toBeUndefined() | ||
}) | ||
|
||
it("should handle invalid planck input", () => { | ||
expect(planckToTokens("abc", 18)).toBe("NaN") | ||
}) | ||
}) |