From 3edb22747ac171982b79180c112a2292b8311f7b Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Tue, 4 Mar 2025 07:57:14 +0100 Subject: [PATCH] feat(curriculum): prioritize showing index.jsx (#59100) --- client/utils/sort-challengefiles.js | 4 ++-- client/utils/sort-challengefiles.test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/utils/sort-challengefiles.js b/client/utils/sort-challengefiles.js index c738abf7fb6..d44461524f5 100644 --- a/client/utils/sort-challengefiles.js +++ b/client/utils/sort-challengefiles.js @@ -1,12 +1,12 @@ exports.sortChallengeFiles = function sortChallengeFiles(challengeFiles) { const xs = challengeFiles.slice(); 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 (b.history[0] === 'index.html') return 1; if (a.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 (b.history[0] === 'script.js') return 1; if (a.history[0] === 'index.ts') return -1; diff --git a/client/utils/sort-challengefiles.test.js b/client/utils/sort-challengefiles.test.js index 72087f5c8dd..6994c7a2f40 100644 --- a/client/utils/sort-challengefiles.test.js +++ b/client/utils/sort-challengefiles.test.js @@ -14,13 +14,13 @@ describe('sort-files', () => { 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 sortedKeys = sorted.map(({ fileKey }) => fileKey); const expected = [ + 'indexjsx', 'indexhtml', 'stylescss', - 'indexjsx', 'scriptjs', 'indexts' ];