forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort-files.test.js
26 lines (23 loc) · 953 Bytes
/
sort-files.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* global expect */
const { toSortedArray } = require('./sort-files');
const { challengeFiles } = require('./__fixtures__/challenges');
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 = Object.values(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 = toSortedArray(challengeFiles);
const sortedKeys = sorted.map(({ key }) => key);
const expected = ['indexhtml', 'indexjsx', 'indexjs', 'indexcss'];
expect(sortedKeys).toStrictEqual(expected);
});
});
});