fix(tools): prevent create-new-x overwriting old projects (#62621)

This commit is contained in:
Oliver Eyton-Williams
2025-10-10 11:58:26 +02:00
committed by GitHub
parent f5361f4341
commit 6fc3684049
5 changed files with 336 additions and 286 deletions
+12 -7
View File
@@ -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'
);
});
});