Skip to content

Commit

Permalink
add test for formatName
Browse files Browse the repository at this point in the history
  • Loading branch information
BushraAbdullahi committed Sep 5, 2024
1 parent 3884283 commit 3b6badb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/services/listCourtCases/formatName.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { formatName } from "../../../src/helpers/formatName"

describe("formatName", () => {
it('should replace spaces with "%" and add "%" at the end', () => {
expect(formatName("John Doe")).toBe("John%Doe%")
})

it('should replace "*" with "%" and add "%" at the end', () => {
expect(formatName("John*Doe")).toBe("John%Doe%")
})

it('should not add another "%" if already present at the end', () => {
expect(formatName("John Doe%")).toBe("John%Doe%")
})

it('should add "%" if there are no spaces or special characters', () => {
expect(formatName("John")).toBe("John%")
})

it("should handle empty string", () => {
expect(formatName("")).toBe("%")
})
})

0 comments on commit 3b6badb

Please sign in to comment.