// let ignoreFiles = ['.npmignore','.gitignore'] import { readLines, writeLines } from '../src/read-lines' import chai from 'chai' import assertArrays from 'chai-arrays' import { it } from 'mocha' chai.use(assertArrays) const expect = chai.expect describe ( 'Read a File of Lines to Array and vice versa', function () { readList() writeList() }) //****************** TESTS ********************** function readList() { it('==> can read one or more files (no order) each line as element in an array with common directory', async function () { const shouldbe = [ 'tests/', 'test/', '*.test.js', 'testing/', 'example/', '/node_modules/', '/coverage/' ] let result = await readLines(['.gitignore','.npmignore'],__dirname) expect(result, 'list build failed').to.be.containingAllOf(shouldbe) }) it('==> can read two files one relative the other absolute', async function () { const shouldbe = [ 'tests/', 'test/', '*.test.js', 'testing/', 'example/', '/node_modules/', '/coverage/' ] let result = await readLines(['./test/.gitignore',__dirname+'/.npmignore']) expect(result, 'list build failed').to.be.containingAllOf(shouldbe) }) } function writeList() { it('==> can write an array items as lines in a file', async function () { const shouldbe = await readLines(['.gitignore','.npmignore'],__dirname) await writeLines(__dirname+'/combined.list',shouldbe) const result = await readLines(['combined.list'],__dirname) expect(result, 'list build failed').to.be.containingAllOf(shouldbe) }) }