mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(client): simplify sort challenge files (#59179)
Co-authored-by: Naomi <accounts+github@nhcarrigan.com>
This commit is contained in:
committed by
GitHub
parent
6e1b87cc78
commit
a82316e469
@@ -0,0 +1,30 @@
|
||||
import { challengeFiles } from './__fixtures__/challenges';
|
||||
import { sortChallengeFiles } from './sort-challengefiles';
|
||||
|
||||
describe('sort-files', () => {
|
||||
describe('sortChallengeFiles', () => {
|
||||
it('should return an array', () => {
|
||||
const sorted = sortChallengeFiles(challengeFiles);
|
||||
expect(Array.isArray(sorted)).toBe(true);
|
||||
});
|
||||
it('should not modify the challenges', () => {
|
||||
const sorted = sortChallengeFiles(challengeFiles);
|
||||
const expected = challengeFiles;
|
||||
expect(sorted).toEqual(expect.arrayContaining(expected));
|
||||
expect(sorted.length).toEqual(expected.length);
|
||||
});
|
||||
|
||||
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',
|
||||
'scriptjs',
|
||||
'indexts'
|
||||
];
|
||||
expect(sortedKeys).toStrictEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user