Skip to content

Commit

Permalink
Add a test case for includeAll option.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Dec 22, 2017
1 parent 0c63b1e commit 3eacad3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ const ROOT = path.join(__dirname, '/../');
describe('constructor', () => {
it('should build an object of versions', () => {
const versions = staticify(ROOT)._versions;

versions.should.be.an.Object();
Object.keys(versions).should.not.equal(0);
});
});

describe('Options work', () => {
it('`ignoreAll: false` works', () => {
const versions = staticify(ROOT, {includeAll: true})._versions;
const matches = Object.keys(versions).filter(ver => ver.match(/node_modules|\.git/)).length > 0;

matches.should.be.true();
});
});

describe('.stripVersion', () => {
it('should strip the hash from a path when necessary', () => {
staticify(ROOT).stripVersion(path.normalize('/script.4e2502b.js')).should.equal(path.normalize('/script.js'));
Expand All @@ -30,6 +40,7 @@ describe('.stripVersion', () => {
describe('.getVersionedPath', () => {
it('should add a hash to the path', () => {
let versioned = staticify(ROOT).getVersionedPath('/index.js');

versioned = versioned.split('.');
versioned.should.have.a.lengthOf(3);
versioned[0].should.equal('/index');
Expand All @@ -40,6 +51,7 @@ describe('.getVersionedPath', () => {

it('should add a long hash to the path', () => {
let versioned = staticify(ROOT, {shortHash: false}).getVersionedPath('/index.js');

versioned = versioned.split('.');
versioned.should.have.a.lengthOf(3);
versioned[0].should.equal('/index');
Expand Down Expand Up @@ -94,6 +106,7 @@ describe('.serve', () => {

describe('long hash', () => {
let server;

before(done => {
server = http.createServer((req, res) => {
staticify(ROOT, {shortHash: false}).serve(req).pipe(res);
Expand Down Expand Up @@ -131,6 +144,7 @@ describe('.serve', () => {

describe('custom serve options', () => {
let server;

before(done => {
server = http.createServer((req, res) => {
staticify(ROOT, {
Expand Down

0 comments on commit 3eacad3

Please sign in to comment.