From aa60aaeb81569265c7f00501f58b68c8fe7d2070 Mon Sep 17 00:00:00 2001 From: Erwan Ameil Date: Mon, 25 Mar 2019 17:24:23 +0000 Subject: [PATCH] Use async writeFile function in test instead of writeFileSync --- test/index.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/test/index.js b/test/index.js index 84724fb..25d3d7a 100644 --- a/test/index.js +++ b/test/index.js @@ -275,25 +275,26 @@ describe('.replacePaths', () => { }); describe('.refresh', () => { - it('should empty the cache of file hashes after a refresh()', () => { - fs.writeFileSync(path.join(__dirname, 'variable_file.txt'), 'File Content 1'); - - const staticifyObj = staticify(ROOT); - - const versionedPath = staticifyObj.getVersionedPath('/test/variable_file.txt'); + it('should empty the cache of file hashes after a refresh()', done => { + fs.writeFile(path.join(__dirname, 'variable_file.txt'), 'File Content 1', () => { + const staticifyObj = staticify(ROOT); - const versioned = versionedPath.split('.'); - versioned.should.have.a.lengthOf(3); - versioned[0].should.equal('/test/variable_file'); - versioned[2].should.equal('txt'); + const versionedPath = staticifyObj.getVersionedPath('/test/variable_file.txt'); - staticifyObj.refresh(); + const versioned = versionedPath.split('.'); + versioned.should.have.a.lengthOf(3); + versioned[0].should.equal('/test/variable_file'); + versioned[2].should.equal('txt'); - fs.writeFileSync(path.join(__dirname, 'variable_file.txt'), 'File Content 2'); + staticifyObj.refresh(); - const versionedPath2 = staticifyObj.getVersionedPath('/test/variable_file.txt'); + fs.writeFile(path.join(__dirname, 'variable_file.txt'), 'File Content 2', () => { + const versionedPath2 = staticifyObj.getVersionedPath('/test/variable_file.txt'); - versionedPath2.should.have.a.lengthOf(31); - versionedPath2.should.not.equal(versionedPath); + versionedPath2.should.have.a.lengthOf(31); + versionedPath2.should.not.equal(versionedPath); + done(); + }); + }); }); });