Skip to content

Commit

Permalink
Add a test for refresh()
Browse files Browse the repository at this point in the history
  • Loading branch information
wan-hellopupil committed Mar 25, 2019
1 parent 945771e commit 80d747e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.nyc_output/
/coverage/
/node_modules/
/test/variable_file.txt
25 changes: 25 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const fs = require('fs');
const http = require('http');
const path = require('path');
const should = require('should');
Expand Down Expand Up @@ -272,3 +273,27 @@ describe('.replacePaths', () => {
results.includes('test/font.woff2').should.be.false();
});
});

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');

const versioned = versionedPath.split('.');
versioned.should.have.a.lengthOf(3);
versioned[0].should.equal('/test/variable_file');
versioned[2].should.equal('txt');

staticifyObj.refresh();

fs.writeFileSync(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);
});
});

0 comments on commit 80d747e

Please sign in to comment.