| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  | const { challengeFiles } = require('./__fixtures__/challenges'); | 
					
						
							| 
									
										
										
										
											2021-10-01 10:36:20 +02:00
										 |  |  | const { sortChallengeFiles } = require('./sort-challengefiles'); | 
					
						
							| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('sort-files', () => { | 
					
						
							| 
									
										
										
										
											2021-10-01 10:36:20 +02:00
										 |  |  |   describe('sortChallengeFiles', () => { | 
					
						
							| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  |     it('should return an array', () => { | 
					
						
							| 
									
										
										
										
											2021-10-01 10:36:20 +02:00
										 |  |  |       const sorted = sortChallengeFiles(challengeFiles); | 
					
						
							| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  |       expect(Array.isArray(sorted)).toBe(true); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     it('should not modify the challenges', () => { | 
					
						
							| 
									
										
										
										
											2021-10-01 10:36:20 +02:00
										 |  |  |       const sorted = sortChallengeFiles(challengeFiles); | 
					
						
							| 
									
										
										
										
											2021-08-12 19:48:28 +01:00
										 |  |  |       const expected = challengeFiles; | 
					
						
							| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  |       expect(sorted).toEqual(expect.arrayContaining(expected)); | 
					
						
							|  |  |  |       expect(sorted.length).toEqual(expected.length); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-24 16:40:18 +02:00
										 |  |  |     it('should sort the objects into html, css, jsx, js order', () => { | 
					
						
							| 
									
										
										
										
											2021-10-01 10:36:20 +02:00
										 |  |  |       const sorted = sortChallengeFiles(challengeFiles); | 
					
						
							| 
									
										
										
										
											2021-08-12 19:48:28 +01:00
										 |  |  |       const sortedKeys = sorted.map(({ fileKey }) => fileKey); | 
					
						
							| 
									
										
										
										
											2021-09-24 16:40:18 +02:00
										 |  |  |       const expected = ['indexhtml', 'indexcss', 'indexjsx', 'indexjs']; | 
					
						
							| 
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 |  |  |       expect(sortedKeys).toStrictEqual(expected); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |