-
Notifications
You must be signed in to change notification settings - Fork 207
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 #1672 from KsAkira10/fix/formatting
fix: fix formatting when add spacing at the beginning and/end
- Loading branch information
Showing
3 changed files
with
50 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,45 @@ | ||
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'); | ||
}); | ||
|
||
it('should handle nil value', () => { | ||
const input = null; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe(undefined); | ||
}); | ||
|
||
it('should handle undefined value', () => { | ||
const input = undefined; | ||
const output = normalizeToKebabOrSnakeCase(input); | ||
expect(output).toBe(undefined); | ||
}); | ||
}); |