-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from bandprotocol/unit-tests
add some unit tests
- Loading branch information
Showing
39 changed files
with
2,059 additions
and
1,364 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
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,14 @@ | ||
open Jest | ||
open Ellipsis | ||
open Expect | ||
|
||
describe("Expect Ellipsis module to work correctly", () => { | ||
test("text length > limit", () => { | ||
expect(format(~text="EDCD7E7A10F564CCCC50B2E382E1924013CB01728EBAFEC1071D2B1D395F82CC", ~limit=25, ()))->toBe("EDCD7E7A10F564CCCC50B2E38...") | ||
}) | ||
|
||
test("text length < limit", () => { | ||
expect(format(~text="EDCD7E7A10F564CCCC50B2E382E1924013CB01728EBAFEC1071D2B1D395F82CC", ~limit=125, ()))->toBe("EDCD7E7A10F564CCCC50B2E382E1924013CB01728EBAFEC1071D2B1D395F82CC") | ||
}) | ||
}) | ||
|
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,74 @@ | ||
open Jest | ||
open Format | ||
open Expect | ||
|
||
describe("Expect Format module to work correctly", () => { | ||
test("withCommas", () => { | ||
expect("10000000"->withCommas)->toBe("10,000,000") | ||
}) | ||
|
||
test("withCommas with decimal digits", () => { | ||
expect("10000000.1234"->withCommas)->toBe("10,000,000.1234") | ||
}) | ||
|
||
test("fPretty value >= 1000000", () => { | ||
expect(10000000.->fPretty)->toBe("10,000,000") | ||
}) | ||
|
||
test("fPretty value > 100.", () => { | ||
expect(1000.123->fPretty)->toBe("1,000.12") | ||
}) | ||
|
||
test("fPretty value > 1.", () => { | ||
expect(3.14285->fPretty)->toBe("3.1429") | ||
}) | ||
|
||
test("fPretty value < 1", () => { | ||
expect(0.123->fPretty)->toBe("0.123000") | ||
}) | ||
|
||
test("fPretty with digit", () => { | ||
expect(10000000.12345678->fPretty(~digits=6))->toBe("10,000,000.123457") | ||
}) | ||
|
||
test("fCurrency value >= 1e9", () => { | ||
expect(12300000000.->fCurrency)->toBe("12.30B") | ||
}) | ||
|
||
test("fCurrency value >= 1e6", () => { | ||
expect(12300000.->fCurrency)->toBe("12.30M") | ||
}) | ||
|
||
test("fCurrency value >= 1e3", () => { | ||
expect(12300.->fCurrency)->toBe("12.30K") | ||
}) | ||
|
||
test("fCurrency else", () => { | ||
expect(123.->fCurrency)->toBe("123.00") | ||
}) | ||
|
||
test("fPercentChange positive", () => { | ||
expect(99.99->fPercentChange)->toBe("+99.99%") | ||
}) | ||
|
||
test("fPercentChange negative", () => { | ||
expect(-99.99->fPercentChange)->toBe("-99.99%") | ||
}) | ||
|
||
test("fPercent", () => { | ||
expect(123456789.->fPercent)->toBe("123,456,789.00 %") | ||
}) | ||
|
||
test("fPercent < 1", () => { | ||
expect(0.12345678->fPercent)->toBe("0.123457 %") | ||
}) | ||
|
||
test("fPercent with digits", () => { | ||
expect(123.45678->fPercent(~digits=4))->toBe("123.4568 %") | ||
}) | ||
|
||
test("iPretty", () => { | ||
expect(10000000->iPretty)->toBe("10,000,000") | ||
}) | ||
}) | ||
|
Oops, something went wrong.
7bfb8b2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cosmoscan-rescript-6feu – ./
cosmoscan-rescript.vercel.app
cosmoscan-rescript-6feu-git-main-band-protocol.vercel.app
cosmoscan-rescript-6feu-band-protocol.vercel.app