feat: update challenge helpers to handle id filenames (#44769)
* refactor: light tweaks for readability * refactor: simplify metadata functions * fix: most tests * test: fix utils tests * test: simplify mocks * WIP: update get-last-step-file-content * feat: finish create-next-step * fix: type error * test: provide mock meta.json for test * refactor: get meta path from project path * refactor: get project name from path * refactor: simplify getProjectMetaPath further Also removes some excessive mocking * refactor: remove more mocks, always clear .env * feat: update create-next-step * feat: update create-empty steps Also refactors slightly, so it's easier to insert steps into the meta * docs: update challenge-helper-script docs * feat: create-step-between * refactor: allow metadata parse errors to propagate * fix: convert reorderSteps to renameSteps * refactor: create-step-between -> insert-step * feat: update delete-step * refactor: consolidate commands into commands.ts * refactor: clean up and consolidation * refactor: more cleanup * fix: make cli args consistent Everything accepts a single integer and nothing else * refactor: renameSteps -> updateStepTitles * docs: update with the names and args * feat: add step validating meta + files are synced
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							16e7cdedb1
						
					
				
				
					commit
					339c6713d2
				
			| @@ -0,0 +1,37 @@ | ||||
| import { getProjectName, getProjectPath } from './get-project-info'; | ||||
|  | ||||
| describe('getProjectPath helper', () => { | ||||
|   it('should return the calling dir path', () => { | ||||
|     const mockCallingDir = 'calling/dir'; | ||||
|     const expected = `${mockCallingDir}/`; | ||||
|  | ||||
|     // Add mock to test condition | ||||
|     process.env.CALLING_DIR = mockCallingDir; | ||||
|  | ||||
|     expect(getProjectPath()).toEqual(expected); | ||||
|  | ||||
|     // Remove mock to not affect other tests | ||||
|     delete process.env.CALLING_DIR; | ||||
|   }); | ||||
|  | ||||
|   it('should return the projects absolute path', () => { | ||||
|     const expected = `${process.cwd()}/`; | ||||
|  | ||||
|     expect(getProjectPath()).toEqual(expected); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| describe('getProjectName helper', () => { | ||||
|   it('should return the last path segment of the calling dir', () => { | ||||
|     const mockCallingDir = 'calling/dir'; | ||||
|     const expected = `dir`; | ||||
|  | ||||
|     // Add mock to test condition | ||||
|     process.env.CALLING_DIR = mockCallingDir; | ||||
|  | ||||
|     expect(getProjectName()).toEqual(expected); | ||||
|  | ||||
|     // Remove mock to not affect other tests | ||||
|     delete process.env.CALLING_DIR; | ||||
|   }); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user