* fix: enforce multifile tab order * fix: sort challengeFiles to prevent remounts If the challengeFiles are used unsorted, this can unmount an editor. The editors rely on the mount hook for initialization, so extra mounts can cause unwanted behaviour. * fix: make editor tabs and panes match
		
			
				
	
	
		
			25 lines
		
	
	
		
			915 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			915 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const { challengeFiles } = require('./__fixtures__/challenges');
 | 
						|
const { toSortedArray } = require('./sort-files');
 | 
						|
 | 
						|
describe('sort-files', () => {
 | 
						|
  describe('toSortedArray', () => {
 | 
						|
    it('should return an array', () => {
 | 
						|
      const sorted = toSortedArray(challengeFiles);
 | 
						|
      expect(Array.isArray(sorted)).toBe(true);
 | 
						|
    });
 | 
						|
    it('should not modify the challenges', () => {
 | 
						|
      const sorted = toSortedArray(challengeFiles);
 | 
						|
      const expected = challengeFiles;
 | 
						|
      expect(sorted).toEqual(expect.arrayContaining(expected));
 | 
						|
      expect(sorted.length).toEqual(expected.length);
 | 
						|
    });
 | 
						|
 | 
						|
    it('should sort the objects into html, css, jsx, js order', () => {
 | 
						|
      const sorted = challengeFiles;
 | 
						|
      const sortedKeys = sorted.map(({ fileKey }) => fileKey);
 | 
						|
      const expected = ['indexhtml', 'indexcss', 'indexjsx', 'indexjs'];
 | 
						|
      expect(sortedKeys).toStrictEqual(expected);
 | 
						|
    });
 | 
						|
  });
 | 
						|
});
 |