Files
freeCodeCamp/utils/sort-files.test.js
Shaun Hamilton 59f17f237b refactor: files{} -> challengeFiles[], and key -> fileKey (#43023)
* fix(client): fix client

* fix propType and add comment

* revert user.json prettification

* slight type refactor and payload correction

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* update ChallengeFile type imports

* add cypress test for code-storage

* update test and storage epic

* fix Shaun's tired brain's logic

* refactor with suggestions

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* update codeReset

* increate cypress timeout because firefox is slow

* remove unused import to make linter happy

* use focus on editor

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* use more specific seletor for cypress editor test

* account for silly null challengeFiles

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2021-08-12 20:48:28 +02:00

25 lines
910 B
JavaScript

const { challengeFiles } = require('./__fixtures__/challenges');
const { toSortedArray } = require('./sort-files');
describe('sort-files', () => {
describe('toSortedArray', () => {
it('should return an array', () => {
const sorted = toSortedArray(challengeFiles);
expect(Array.isArray(sorted)).toBe(true);
});
it('should not modify the challenges', () => {
const sorted = toSortedArray(challengeFiles);
const expected = challengeFiles;
expect(sorted).toEqual(expect.arrayContaining(expected));
expect(sorted.length).toEqual(expected.length);
});
it('should sort the objects into html, js, css order', () => {
const sorted = challengeFiles;
const sortedKeys = sorted.map(({ fileKey }) => fileKey);
const expected = ['indexhtml', 'indexjsx', 'indexjs', 'indexcss'];
expect(sortedKeys).toStrictEqual(expected);
});
});
});