diff --git a/CHANGELOG.md b/CHANGELOG.md index 07dbd4fea..a69012617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#769](https://github.com/alleslabs/celatone-frontend/pull/769) Add unit test for format.test.ts on shortenName function - [#768](https://github.com/alleslabs/celatone-frontend/pull/768) Add unit test for truncate.test.ts - [#767](https://github.com/alleslabs/celatone-frontend/pull/767) Add unit test for fee.test.ts - [#756](https://github.com/alleslabs/celatone-frontend/pull/756) Redirect usei to homepage diff --git a/src/lib/utils/format.test.ts b/src/lib/utils/format.test.ts new file mode 100644 index 000000000..112039515 --- /dev/null +++ b/src/lib/utils/format.test.ts @@ -0,0 +1,21 @@ +import { shortenName } from "./format"; + +describe("shortenName validation", () => { + test("standard case", () => { + const name = shortenName("Generate my sentence"); + + expect(name).toBe("Generate m..."); + }); + + test("custom truncate length", () => { + const name = shortenName("Hello World!", 5); + + expect(name).toBe("Hello..."); + }); + + test("custom truncate length with longer than input string", () => { + const name = shortenName("Hello", 20); + + expect(name).toBe("Hello"); + }); +});