feat(curriculum): prioritize showing index.jsx (#59100)

This commit is contained in:
Oliver Eyton-Williams
2025-03-04 07:57:14 +01:00
committed by GitHub
parent 701afe1fe5
commit 3edb22747a
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
exports.sortChallengeFiles = function sortChallengeFiles(challengeFiles) { exports.sortChallengeFiles = function sortChallengeFiles(challengeFiles) {
const xs = challengeFiles.slice(); const xs = challengeFiles.slice();
xs.sort((a, b) => { xs.sort((a, b) => {
if (a.history[0] === 'index.jsx') return -1;
if (b.history[0] === 'index.jsx') return 1;
if (a.history[0] === 'index.html') return -1; if (a.history[0] === 'index.html') return -1;
if (b.history[0] === 'index.html') return 1; if (b.history[0] === 'index.html') return 1;
if (a.history[0] === 'styles.css') return -1; if (a.history[0] === 'styles.css') return -1;
if (b.history[0] === 'styles.css') return 1; if (b.history[0] === 'styles.css') return 1;
if (a.history[0] === 'index.jsx') return -1;
if (b.history[0] === 'index.jsx') return 1;
if (a.history[0] === 'script.js') return -1; if (a.history[0] === 'script.js') return -1;
if (b.history[0] === 'script.js') return 1; if (b.history[0] === 'script.js') return 1;
if (a.history[0] === 'index.ts') return -1; if (a.history[0] === 'index.ts') return -1;
+2 -2
View File
@@ -14,13 +14,13 @@ describe('sort-files', () => {
expect(sorted.length).toEqual(expected.length); expect(sorted.length).toEqual(expected.length);
}); });
it('should sort the objects into html, css, jsx, js, ts order', () => { it('should sort the objects into jsx, html, css, js, ts order', () => {
const sorted = sortChallengeFiles(challengeFiles); const sorted = sortChallengeFiles(challengeFiles);
const sortedKeys = sorted.map(({ fileKey }) => fileKey); const sortedKeys = sorted.map(({ fileKey }) => fileKey);
const expected = [ const expected = [
'indexjsx',
'indexhtml', 'indexhtml',
'stylescss', 'stylescss',
'indexjsx',
'scriptjs', 'scriptjs',
'indexts' 'indexts'
]; ];