feat: allow TS to be used in challenges (#56159)

This commit is contained in:
Oliver Eyton-Williams
2024-09-20 00:44:09 +02:00
committed by GitHub
parent 349fca83de
commit 8b601d762e
6 changed files with 37 additions and 4 deletions
+14
View File
@@ -1,6 +1,20 @@
import { ChallengeFile } from "../../src/redux/prop-types";
export const challengeFiles: ChallengeFile[] = [
{
id: '0',
contents: 'some ts',
error: null,
ext: 'ts',
head: '',
history: ['index.ts'],
fileKey: 'indexts',
name: 'index',
seed: 'some ts',
tail: '',
editableRegionBoundaries: [],
usesMultifileEditor: true,
},
{
id: '1',
contents: 'some css',
+2
View File
@@ -9,6 +9,8 @@ exports.sortChallengeFiles = function sortChallengeFiles(challengeFiles) {
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;
if (b.history[0] === 'index.ts') return 1;
return 0;
});
return xs;
+8 -2
View File
@@ -14,10 +14,16 @@ describe('sort-files', () => {
expect(sorted.length).toEqual(expected.length);
});
it('should sort the objects into html, css, jsx, js order', () => {
it('should sort the objects into html, css, jsx, js, ts order', () => {
const sorted = sortChallengeFiles(challengeFiles);
const sortedKeys = sorted.map(({ fileKey }) => fileKey);
const expected = ['indexhtml', 'stylescss', 'indexjsx', 'scriptjs'];
const expected = [
'indexhtml',
'stylescss',
'indexjsx',
'scriptjs',
'indexts'
];
expect(sortedKeys).toStrictEqual(expected);
});
});