2020-06-01 18:28:22 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const { challengeFiles } = require('./__fixtures__/challenges');
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-02 15:39:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const { toSortedArray } = require('./sort-files');
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								describe('sort-files', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-08 16:23:09 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  describe('toSortedArray', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('should return an array', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-08 16:23:09 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const sorted = toSortedArray(challengeFiles);
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(Array.isArray(sorted)).toBe(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('should not modify the challenges', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-08 16:23:09 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const sorted = toSortedArray(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);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    it('should sort the objects into html, js, css order', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-12 19:48:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const sorted = challengeFiles;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const sortedKeys = sorted.map(({ fileKey }) => fileKey);
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-03 15:24:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const expected = ['indexhtml', 'indexjsx', 'indexjs', 'indexcss'];
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-01 18:28:22 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(sortedKeys).toStrictEqual(expected);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 |