Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Feb 5, 2018
1 parent f313df8 commit b2eb03e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/fixtures/dist/app.css.br
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
�body: {}

2 changes: 1 addition & 1 deletion tests/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('s3 plugin', function() {
return previous;
}, []);

assert.equal(messages.length, 7);
assert.equal(messages.length, 8);
});

describe('required config', function() {
Expand Down
30 changes: 30 additions & 0 deletions tests/lib/s3-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,36 @@ describe('s3', function() {
});
});

it('sends the correct content type params for brotli-compressed files with .br extension', function () {
var s3Params;
s3Client.putObject = function (params, cb) {
s3Params = params;
cb();
};

var options = {
filePaths: ['app.css', 'app.css.br'],
brotliCompressedFilePaths: ['app.css.br'],
cwd: process.cwd() + '/tests/fixtures/dist',
prefix: 'js-app',
acl: 'public-read',
bucket: 'some-bucket',
cacheControl: 'max-age=1234, public',
expires: '2010'
};

var promises = subject.upload(options);

return assert.isFulfilled(promises)
.then(function () {
assert.equal(s3Params.ContentType, 'text/css; charset=utf-8');
assert.equal(s3Params.Key, 'js-app/app.css.br');
assert.equal(s3Params.ContentEncoding, 'br');
assert.equal(s3Params.CacheControl, 'max-age=1234, public');
assert.equal(s3Params.Expires, '2010');
});
});

it('sets the content type using defaultMimeType', function() {
var s3Params;
s3Client.putObject = function(params, cb) {
Expand Down

0 comments on commit b2eb03e

Please sign in to comment.