const should = require("chai").should();
const mock = require('mock-fs');

const io = require("../");

describe("file-io", () => {
    describe("read", () => {
        it("should open files matching glob", (done) => {
            const path = "fake-dir/target-file.js";
            const mockedFile = { [path]: "" }; 
            mock(mockedFile);
            
            io.open("**/*.js").then(files => {
                files.should.exist;
                files.should.include(path);
                mock.restore();
                done();
            }, err => {
                console.log(err);
                mock.restore();
                done();
            });
        });
        
        it("should read file", (done) => {
            const path = "fake-dir/read-target-file";
            const content = "reading lorem ipsum";
            const mockedFile = { [path]: content }; 
            mock(mockedFile);
            
            io.read(path).then(data => {
                data.should.equal(content);
                mock.restore();
                done();
            }, err => {
               console.log(err);
               mock.restore();
               done();
            });
        });
    });
    
    describe("write", () => {
        it("should write content to file", (done) => {
            const path = "fake-dir/write-target-file";
            const content = "writing lorem ipsum";
            const mockedFile = { [path]: '' }; 
            mock(mockedFile);
            
            io.write(path, content).then(file => {
                io.read(path).then(data => {
                    data.should.equal(content);
                    mock.restore();
                    done();
                }, err => {
                    console.log(err);
                    mock.restore();    
                    done(); 
                });
            }, err => {
               console.log(err);
               mock.restore();
               done();
            });
        });
    });
});
@@ -138,20 +138,20 @@
 scribe(%22
-read
+open
 %22, () =%3E
@@ -679,28 +679,57 @@
     %7D);%0A    
-    
+%7D);%0A%0A    describe(%22read%22, () =%3E %7B
 %0A        it(
@@ -1133,32 +1133,33 @@
 %0A               
+ 
 console.log(err)
@@ -1167,32 +1167,33 @@
 %0A               
+ 
 mock.restore();%0A
@@ -1184,32 +1184,33 @@
 mock.restore();%0A
+ 
                d
@@ -1933,32 +1933,33 @@
 %0A               
+ 
 console.log(err)
@@ -1967,32 +1967,33 @@
 %0A               
+ 
 mock.restore();%0A
@@ -1984,32 +1984,33 @@
 mock.restore();%0A
+ 
                d

Give 'open' its own description in test