Skip to content

Commit

Permalink
still trying to debug weirdness with "gzip-suffix" strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Aug 26, 2013
1 parent 6c2a427 commit 3316359
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ FileList.prototype.constructor = FileList;
* @return {Promise} covering the promises of all contained Files
*/
FileList.prototype.ready = function () {
return Q.all(this.map(function (file) {
var dfrd, me;
me = this;
dfrd = Q.defer();
Q.all(this.map(function (file) {
return file.promise;
}));
})).done(function () {
dfrd.resolve(me);
}, dfrd.reject);
return dfrd.promise;
};

/**
Expand Down
40 changes: 38 additions & 2 deletions test/filelist_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ path = require('path');

// 3rd-party modules

var chai, assert, sinon;
var chai, assert, sinon, Q;

chai = require('chai');
chai.use(require('sinon-chai'));
assert = require('chai').assert;
sinon = require('sinon');
Q = require('q');

// custom modules

Expand Down Expand Up @@ -248,7 +249,7 @@ suite('fileList.applyStrategy ["clone", "gzip-suffix"]', function () {
}, done);
});

test('files contains ' + filename, function () {
test('originalFiles contains ' + filename, function () {
assert(originalFiles.indexOf(filename) !== -1, 'known file included');
});

Expand All @@ -265,6 +266,41 @@ suite('fileList.applyStrategy ["clone", "gzip-suffix"]', function () {
});
});

test('files.ready', function () {
var promise;
assert.isFunction(files.ready, 'files.ready is a function');
promise = files.ready();
assert.isTrue(Q.isPromise(promise), 'files.ready returns a promise');
});

test('files.constructor', function () {
assert.isFunction(files.constructor, 'files.constructor is a function');
assert.equal(files.constructor, FileList, 'constructor function');
});

test('files.indexOf', function () {
assert.isFunction(files.indexOf, 'files.indexOf is a function');
assert.equal(files.indexOf, FileList.prototype.indexOf, 'prototyped');
});

test('originalFiles still contains ' + filename, function () {
assert(originalFiles.indexOf(filename) !== -1, 'known file included');
});

test('files contains ' + filename, function () {
assert(files.some(function (f) {
return f.path === filename;
}), 'known file included');
assert(files.indexOf(filename) !== -1, 'known file index found');
});

test('files contains ' + filename + '.gz', function () {
assert(files.some(function (f) {
return f.path === (filename + '.gz');
}), 'known file included');
assert(files.indexOf(filename + '.gz') !== -1, 'known file index found');
});

test('doubles the number of files', function () {
assert.equal(files.length, originalLength * 2, files.length + ' file(s)');
});
Expand Down

0 comments on commit 3316359

Please sign in to comment.