mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
Some checks failed
Docker -- GHCR - Gitpod / build-and-push-image (gitpod) (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (20.x) (push) Has been cancelled
CI - Node.js / Lint (20.x) (push) Has been cancelled
i18n - Upload Client UI / Client (push) Has been cancelled
i18n - Upload Curriculum / Learn (push) Has been cancelled
CI - Node.js / Build (20.x) (push) Has been cancelled
CI - Node.js / Test (20.x) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20.x) (push) Has been cancelled
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
const { challengeFiles } = require('./__fixtures__/challenges');
|
|
const { sortChallengeFiles } = require('./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 html, css, jsx, js, ts order', () => {
|
|
const sorted = sortChallengeFiles(challengeFiles);
|
|
const sortedKeys = sorted.map(({ fileKey }) => fileKey);
|
|
const expected = [
|
|
'indexhtml',
|
|
'stylescss',
|
|
'indexjsx',
|
|
'scriptjs',
|
|
'indexts'
|
|
];
|
|
expect(sortedKeys).toStrictEqual(expected);
|
|
});
|
|
});
|
|
});
|