UNPKG

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