1 | const { deepEqual } = require('assert-diff')
|
2 | const path = require('path')
|
3 | const lib = require('../../src/lib/')
|
4 |
|
5 | const array = [
|
6 | 'file.txt',
|
7 | {
|
8 | dirA: ['file2.txt'],
|
9 | dirB: [],
|
10 | dirC: [
|
11 | 'file3.txt',
|
12 | {
|
13 | dirC1: ['file4.txt'],
|
14 | },
|
15 | ],
|
16 | },
|
17 | ]
|
18 |
|
19 | const libTestSuite = {
|
20 | flatten: {
|
21 | 'should return a list of all files': () => {
|
22 | const res = lib.flatten(array)
|
23 | deepEqual(res, [
|
24 | 'file.txt',
|
25 | path.join('dirA', 'file2.txt'),
|
26 | path.join('dirC', 'file3.txt'),
|
27 | path.join('dirC', 'dirC1', 'file4.txt'),
|
28 | ])
|
29 | },
|
30 | },
|
31 | flattenAll: {
|
32 | 'should return a list of all files and folders': () => {
|
33 | const res = lib.flattenAll(array)
|
34 | deepEqual(res, [
|
35 | 'file.txt',
|
36 | 'dirA/file2.txt',
|
37 | 'dirC/file3.txt',
|
38 | 'dirC/dirC1/file4.txt',
|
39 | 'dirC/dirC1',
|
40 | 'dirA',
|
41 | 'dirB',
|
42 | 'dirC',
|
43 | ])
|
44 | },
|
45 | },
|
46 | }
|
47 |
|
48 |
|
49 | module.exports = libTestSuite
|