mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-28 03:49:22 +08:00
chore(utils): migrate block-nameify to TS and add unit tests (#48086)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { blockNameify } from './block-nameify';
|
||||
|
||||
describe('blockNameify', () => {
|
||||
it('should return a preformatted name when it exists', () => {
|
||||
const result = blockNameify('back-end-development-and-apis');
|
||||
expect(result).toBe('Back End Development and APIs');
|
||||
});
|
||||
|
||||
it('should not format prepositions', () => {
|
||||
const result = blockNameify('and-for-of-the-up-with');
|
||||
expect(result).toBe('and for of the up with');
|
||||
});
|
||||
|
||||
it('should format javascript to JavaScript', () => {
|
||||
const result = blockNameify('javascript');
|
||||
expect(result).toBe('JavaScript');
|
||||
});
|
||||
|
||||
it('should transform "-" to " " and uppercase each word', () => {
|
||||
const result = blockNameify('hello-world');
|
||||
expect(result).toBe('Hello World');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user