fix(path-map): Refactor pathMigrationMap for new curriculum package
This commit is contained in:
		
				
					committed by
					
						 mrugesh mohapatra
						mrugesh mohapatra
					
				
			
			
				
	
			
			
			
						parent
						
							bc9b3b4ddd
						
					
				
				
					commit
					d52ba8c6fd
				
			
							
								
								
									
										32
									
								
								tools/scripts/seed/createPathMigrationMap.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								tools/scripts/seed/createPathMigrationMap.test.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| /* global describe expect */ | ||||
| const { isPlainObject } = require('lodash'); | ||||
|  | ||||
| const { createPathMigrationMap } = require('./createPathMigrationMap'); | ||||
| const mockCurriculum = require('./__mocks__/curriculum.json'); | ||||
|  | ||||
| describe('createPathMigrationMap', () => { | ||||
|   const pathMap = createPathMigrationMap(mockCurriculum); | ||||
|  | ||||
|   it('is a function', () => { | ||||
|     expect(typeof createPathMigrationMap).toEqual('function'); | ||||
|   }); | ||||
|  | ||||
|   it('returns an object', () => { | ||||
|     expect(isPlainObject(pathMap)).toBe(true); | ||||
|   }); | ||||
|  | ||||
|   it('maps a challenge title to the correct uri slug', () => { | ||||
|     expect.assertions(3); | ||||
|     const slugOne = '/learn/super-block-b/block-one/challenge-ten'; | ||||
|     const slugTwo = '/learn/super-block-a/block-two/challenge-five'; | ||||
|     const slugThree = '/learn/super-block-a/block-one/challenge-three'; | ||||
|  | ||||
|     expect(pathMap['challenge-ten']).toEqual(slugOne); | ||||
|     expect(pathMap['challenge-five']).toEqual(slugTwo); | ||||
|     expect(pathMap['challenge-three']).toEqual(slugThree); | ||||
|   }); | ||||
|  | ||||
|   it('does not add uri migrations for private challenges', () => { | ||||
|     expect(pathMap['challenge-nine']).toBeUndefined(); | ||||
|   }); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user