-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix builder name and rewards leaderboard name alignment (#400)
- Loading branch information
Showing
5 changed files
with
80 additions
and
21 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
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,46 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { removeBrackets } from './removeBrackets' | ||
|
||
describe('formatBuilderName', () => { | ||
it('should remove the initial text enclosed with []', () => { | ||
const input = '[Initial Text] Remaining Text' | ||
const expectedOutput = 'Remaining Text' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should return the same string if no text is enclosed with []', () => { | ||
const input = 'No brackets here' | ||
const expectedOutput = 'No brackets here' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should handle strings with multiple brackets correctly', () => { | ||
const input = '[Initial] [Text] Remaining Text' | ||
const expectedOutput = '[Text] Remaining Text' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should not remove the chars after the bracket if it is not an empty space', () => { | ||
const input = '[Initial][Text] Remaining Text' | ||
const expectedOutput = '[Text] Remaining Text' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should handle empty strings correctly', () => { | ||
const input = '' | ||
const expectedOutput = '' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should handle strings with only brackets correctly', () => { | ||
const input = '[]' | ||
const expectedOutput = '' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
|
||
it('should handle undefined also', () => { | ||
const input = undefined | ||
const expectedOutput = '' | ||
expect(removeBrackets(input)).toBe(expectedOutput) | ||
}) | ||
}) |
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,10 @@ | ||
export const removeBrackets = (name?: string) => { | ||
if (!name) { | ||
return '' | ||
} | ||
const bracketIndex = name.indexOf(']') | ||
if (bracketIndex !== -1) { | ||
return name.slice(bracketIndex + 1).trimStart() | ||
} | ||
return name | ||
} |