mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: allow TS to be used in challenges (#56159)
This commit is contained in:
committed by
GitHub
parent
349fca83de
commit
8b601d762e
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user