Skip to content

Commit

Permalink
Use async writeFile function in test instead of writeFileSync
Browse files Browse the repository at this point in the history
  • Loading branch information
wan-hellopupil committed Mar 25, 2019
1 parent 80d747e commit aa60aae
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
});

0 comments on commit aa60aae

Please sign in to comment.