Skip to content

Commit aa60aae

Browse files
Use async writeFile function in test instead of writeFileSync
1 parent 80d747e commit aa60aae

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

test/index.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,25 +275,26 @@ describe('.replacePaths', () => {
275275
});
276276

277277
describe('.refresh', () => {
278-
it('should empty the cache of file hashes after a refresh()', () => {
279-
fs.writeFileSync(path.join(__dirname, 'variable_file.txt'), 'File Content 1');
280-
281-
const staticifyObj = staticify(ROOT);
282-
283-
const versionedPath = staticifyObj.getVersionedPath('/test/variable_file.txt');
278+
it('should empty the cache of file hashes after a refresh()', done => {
279+
fs.writeFile(path.join(__dirname, 'variable_file.txt'), 'File Content 1', () => {
280+
const staticifyObj = staticify(ROOT);
284281

285-
const versioned = versionedPath.split('.');
286-
versioned.should.have.a.lengthOf(3);
287-
versioned[0].should.equal('/test/variable_file');
288-
versioned[2].should.equal('txt');
282+
const versionedPath = staticifyObj.getVersionedPath('/test/variable_file.txt');
289283

290-
staticifyObj.refresh();
284+
const versioned = versionedPath.split('.');
285+
versioned.should.have.a.lengthOf(3);
286+
versioned[0].should.equal('/test/variable_file');
287+
versioned[2].should.equal('txt');
291288

292-
fs.writeFileSync(path.join(__dirname, 'variable_file.txt'), 'File Content 2');
289+
staticifyObj.refresh();
293290

294-
const versionedPath2 = staticifyObj.getVersionedPath('/test/variable_file.txt');
291+
fs.writeFile(path.join(__dirname, 'variable_file.txt'), 'File Content 2', () => {
292+
const versionedPath2 = staticifyObj.getVersionedPath('/test/variable_file.txt');
295293

296-
versionedPath2.should.have.a.lengthOf(31);
297-
versionedPath2.should.not.equal(versionedPath);
294+
versionedPath2.should.have.a.lengthOf(31);
295+
versionedPath2.should.not.equal(versionedPath);
296+
done();
297+
});
298+
});
298299
});
299300
});

0 commit comments

Comments
 (0)