mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(tools): prevent create-new-x overwriting old projects (#62621)
This commit is contained in:
committed by
GitHub
parent
f5361f4341
commit
6fc3684049
@@ -98,24 +98,29 @@ describe('Challenge utils helper scripts', () => {
|
||||
describe('createProject util', () => {
|
||||
it('should allow alphanumerical names with trailing whitespace', () => {
|
||||
expect(
|
||||
validateBlockName('learn-callbacks-by-creating-a-bookshelf ')
|
||||
validateBlockName('learn-callbacks-by-creating-a-bookshelf ', [])
|
||||
).toBe(true);
|
||||
});
|
||||
it('should allow alphanumerical names with no trailing whitespace', () => {
|
||||
expect(validateBlockName('learn-callbacks-by-creating-a-bookshelf')).toBe(
|
||||
true
|
||||
);
|
||||
expect(
|
||||
validateBlockName('learn-callbacks-by-creating-a-bookshelf', [])
|
||||
).toBe(true);
|
||||
});
|
||||
it('should not allow non-kebab case names', () => {
|
||||
expect(validateBlockName('learnCallbacksBetter')).toBe(
|
||||
expect(validateBlockName('learnCallbacksBetter', [])).toBe(
|
||||
'please use alphanumerical characters and kebab case'
|
||||
);
|
||||
});
|
||||
it('should not allow white space names', () => {
|
||||
expect(validateBlockName(' ')).toBe('please enter a dashed name');
|
||||
expect(validateBlockName(' ', [])).toBe('please enter a dashed name');
|
||||
});
|
||||
it('should not allow empty names', () => {
|
||||
expect(validateBlockName('')).toBe('please enter a dashed name');
|
||||
expect(validateBlockName('', [])).toBe('please enter a dashed name');
|
||||
});
|
||||
it('should not allow names that already exist', () => {
|
||||
expect(validateBlockName('name', ['name'])).toBe(
|
||||
'a block with this name already exists'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user