'use strict'

import chai from 'chai'
const should = chai.should
const expect = chai.expect

import fileIo from '../src/js/file-io'

describe('list files', function () {
  const list = fileIo.getFilenames('.')
  console.log(list)

  it('reads directory without error', function () {
    expect(fileIo.getFilenames('.')).to.be.a('array')
  })

  it('returns at least 3 filenames', function () {
    expect(fileIo.getFilenames('.')).to.have.length.of.at.least(3)
  })

  it('throws an error when directory does not exist', function () {
    try {
      fileIo.getFilenames('/nowhere')
    } catch (err) {
      expect(err).to.have.property('code').equal('ENOENT')
    }
  })
})

describe('save and load file', function () {
  const path = 'test.txt'
  
  it('save file without error', function () {
    fileIo.saveWithBase64(path, 'aaa')
  })

  it('load file without error', function () {
    const buf = fileIo.load(path)
    expect(buf).to.be.a('string')
  })
})

@@ -7,16 +7,36 @@
 trict'%0A%0A
+import fs from 'fs'%0A
 import c
@@ -968,16 +968,125 @@
 string')
+%0A%0A    expect(buf).to.contain('aaa')%0A  %7D)%0A%0A  after (function (done) %7B%0A    fs.unlinkSync('test.txt')%0A    done()
 %0A  %7D)%0A%7D)

Add cleaning after test