-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix formatting when add spacing at the beginning and/end
- Loading branch information
Lucas Akira Uehara
committed
Jan 18, 2024
1 parent
2013047
commit 7e2503e
Showing
3 changed files
with
38 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
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,33 @@ | ||
import { normalizeToKebabOrSnakeCase } from '../../src/utils'; | ||
|
||
describe('normalizeToKebabOrSnakeCase', () => { | ||
it('should convert camelCase to kebab-case', () => { | ||
const input = 'camelCaseString'; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe('camel-case-string'); | ||
}); | ||
|
||
it('should replace spaces with dashes', () => { | ||
const input = 'string with spaces'; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe('string-with-spaces'); | ||
}); | ||
|
||
it('should keep underscores', () => { | ||
const input = 'string_with_underscores'; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe('string_with_underscores'); | ||
}); | ||
|
||
it('should handle empty string', () => { | ||
const input = ''; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe(''); | ||
}); | ||
|
||
it('should handle strings with leading/trailing spaces', () => { | ||
const input = ' leading and trailing spaces '; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe('leading-and-trailing-spaces'); | ||
}); | ||
}); |