freeCodeCamp/utils/sort-challengefiles.test.js
Oliver Eyton-Williams f613a1e5fd
fix: index.css/js to styles/script (#44356)
* fix: replace index with script/styles as needed

* fix: remove redundant fileKey

It's overwritten by createPoly, so the parser does not need to create it

* fix: curriculum test suite

* Update client/src/templates/Challenges/classic/MultifileEditor.js

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
2021-12-03 12:32:29 -08:00

25 lines
966 B
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 order', () => {
const sorted = sortChallengeFiles(challengeFiles);
const sortedKeys = sorted.map(({ fileKey }) => fileKey);
const expected = ['indexhtml', 'stylescss', 'indexjsx', 'scriptjs'];
expect(sortedKeys).toStrictEqual(expected);
});
});
});