UNPKG

1.52 kBJavaScriptView Raw
1import path from 'path';
2import { expect } from 'chai';
3import getFiles from '../src/getFiles';
4
5const assetsPath = path.resolve(__dirname, 'assets');
6
7describe('getFiles', () => {
8 it('get recursively the files in the output path', () => {
9 const files = getFiles(assetsPath);
10 expect(files).to.have.length(7);
11 expect(files).to.include(`${assetsPath}/folder/p.txt`);
12 expect(files).to.include(`${assetsPath}/folder/q.txt`);
13 expect(files).to.include(`${assetsPath}/a.txt`);
14 expect(files).to.include(`${assetsPath}/b.txt`);
15 expect(files).to.include(`${assetsPath}/bundle.js`);
16 expect(files).to.include(`${assetsPath}/foo.json`);
17 expect(files).to.include(`${assetsPath}/z.txt`);
18 });
19 it('exclude files from array', () => {
20 const files = getFiles(assetsPath, ['a.txt', 'b.txt']);
21 expect(files).to.have.length(5);
22 expect(files).to.not.include(`${assetsPath}/a.txt`);
23 expect(files).to.not.include(`${assetsPath}/b.txt`);
24 });
25 it('exclude files from glob', () => {
26 const files = getFiles(assetsPath, ['folder/**/*.txt']);
27 expect(files).to.have.length(5);
28 expect(files).to.not.include(`${assetsPath}/folder/p.txt`);
29 expect(files).to.not.include(`${assetsPath}/folder/q.txt`);
30 expect(files).to.include(`${assetsPath}/a.txt`);
31 expect(files).to.include(`${assetsPath}/b.txt`);
32 expect(files).to.include(`${assetsPath}/bundle.js`);
33 expect(files).to.include(`${assetsPath}/foo.json`);
34 expect(files).to.include(`${assetsPath}/z.txt`);
35 });
36});