-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert variants: check for large difference in amount (#3958)
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 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
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,21 @@ | ||
import { Dec } from "@keplr-wallet/unit"; | ||
|
||
import { checkLargeAmountDiff } from "../use-convert-variant"; | ||
|
||
describe("isLargeAmountDiff", () => { | ||
test("returns false when input amount is zero", () => { | ||
expect(checkLargeAmountDiff(new Dec("0"), new Dec("100"))).toBe(false); | ||
}); | ||
|
||
test("returns false when output is 95% or more of input", () => { | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("95"))).toBe(false); | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("96"))).toBe(false); | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("100"))).toBe(false); | ||
}); | ||
|
||
test("returns true when output is less than 95% of input", () => { | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("94"))).toBe(true); | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("90"))).toBe(true); | ||
expect(checkLargeAmountDiff(new Dec("100"), new Dec("50"))).toBe(true); | ||
}); | ||
}); |
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