2020-06-01 16:28:22 +00:00
|
|
|
const { challengeFiles } = require('./__fixtures__/challenges');
|
2021-10-01 08:36:20 +00:00
|
|
|
const { sortChallengeFiles } = require('./sort-challengefiles');
|
2020-06-01 16:28:22 +00:00
|
|
|
|
|
|
|
describe('sort-files', () => {
|
2021-10-01 08:36:20 +00:00
|
|
|
describe('sortChallengeFiles', () => {
|
2020-06-01 16:28:22 +00:00
|
|
|
it('should return an array', () => {
|
2021-10-01 08:36:20 +00:00
|
|
|
const sorted = sortChallengeFiles(challengeFiles);
|
2020-06-01 16:28:22 +00:00
|
|
|
expect(Array.isArray(sorted)).toBe(true);
|
|
|
|
});
|
|
|
|
it('should not modify the challenges', () => {
|
2021-10-01 08:36:20 +00:00
|
|
|
const sorted = sortChallengeFiles(challengeFiles);
|
2021-08-12 18:48:28 +00:00
|
|
|
const expected = challengeFiles;
|
2020-06-01 16:28:22 +00:00
|
|
|
expect(sorted).toEqual(expect.arrayContaining(expected));
|
|
|
|
expect(sorted.length).toEqual(expected.length);
|
|
|
|
});
|
|
|
|
|
2021-09-24 14:40:18 +00:00
|
|
|
it('should sort the objects into html, css, jsx, js order', () => {
|
2021-10-01 08:36:20 +00:00
|
|
|
const sorted = sortChallengeFiles(challengeFiles);
|
2021-08-12 18:48:28 +00:00
|
|
|
const sortedKeys = sorted.map(({ fileKey }) => fileKey);
|
2021-12-03 20:32:29 +00:00
|
|
|
const expected = ['indexhtml', 'stylescss', 'indexjsx', 'scriptjs'];
|
2020-06-01 16:28:22 +00:00
|
|
|
expect(sortedKeys).toStrictEqual(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|