|
| 1 | +/* global describe it */ |
| 2 | +'use strict' |
| 3 | + |
| 4 | +const { findFiles, cwd } = require('../../lib/utils') |
| 5 | +const chai = require('chai') |
| 6 | +const path = require('path') |
| 7 | +const expect = chai.expect |
| 8 | + |
| 9 | +describe('findFiles', () => { |
| 10 | + it('non recursive', () => { |
| 11 | + const files = findFiles(`${cwd()}/test/fixtures`, false, ['html']) |
| 12 | + expect(files).to.have.lengthOf(1) |
| 13 | + expect(files).has.deep.members([ |
| 14 | + { filePath: path.join(cwd(), 'test', 'fixtures'), fileName: 'file-to-test.html' } |
| 15 | + ]) |
| 16 | + }) |
| 17 | + it('recursive', () => { |
| 18 | + const files = findFiles(`${cwd()}/test/fixtures`, true, ['html']) |
| 19 | + expect(files).to.have.lengthOf(5) |
| 20 | + expect(files).has.deep.members([ |
| 21 | + { filePath: path.join(cwd(), 'test', 'fixtures'), fileName: 'file-to-test.html' }, |
| 22 | + { filePath: path.join(cwd(), 'test', 'fixtures', 'html-files'), fileName: 'brokenHttpLinksChecker_127_0_0_2.html' }, |
| 23 | + { filePath: path.join(cwd(), 'test', 'fixtures', 'html-files'), fileName: 'brokenHttpLinksChecker_github.com.html' }, |
| 24 | + { filePath: path.join(cwd(), 'test', 'fixtures', 'html-files'), fileName: 'brokenHttpLinksChecker_localhost.html' }, |
| 25 | + { filePath: path.join(cwd(), 'test', 'fixtures', 'sub_dr'), fileName: 'brokenHttpLinksChecker.html' } |
| 26 | + ]) |
| 27 | + }) |
| 28 | + it('empty extensions', () => { |
| 29 | + const files = findFiles(`${cwd()}/test/fixtures`, true, []) |
| 30 | + expect(files).to.have.lengthOf(0) |
| 31 | + }) |
| 32 | +}) |
0 commit comments