Skip to content

Commit

Permalink
lock down content-type headers in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Aug 20, 2023
1 parent 887efe7 commit 1892226
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 37 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/lib/resource-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function isLocalLink(url = '') {
function transformKoaRequestIntoStandardRequest(url, request) {
const { body, method, header } = request;

// https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#parameters
return new Request(url, {
body: ['GET', 'HEAD'].includes(method.toUpperCase())
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/css');
expect(response.headers['content-type']).to.equal('text/css');
done();
});

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/cases/develop.spa/develop.spa.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/css');
expect(response.headers['content-type']).to.equal('text/css');
done();
});

Expand Down Expand Up @@ -251,7 +251,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/css');
expect(response.headers['content-type']).to.equal('text/css');
done();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -162,7 +162,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
12 changes: 6 additions & 6 deletions packages/cli/test/cases/serve.default/serve.default.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json; charset=utf-8');
done();
});

Expand Down Expand Up @@ -133,7 +133,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json; charset=utf-8');
done();
});

Expand Down Expand Up @@ -310,7 +310,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain(ext);
expect(response.headers['content-type']).to.equal(`video/${ext}`);
done();
});

Expand Down Expand Up @@ -349,7 +349,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('audio/mpeg');
expect(response.headers['content-type']).to.equal('audio/mpeg');
done();
});

Expand Down Expand Up @@ -388,7 +388,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json');
done();
});

Expand Down Expand Up @@ -422,7 +422,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json');
done();
});

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/cases/serve.spa/serve.spa.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -169,7 +169,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/cases/theme-pack/theme-pack.develop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/css');
expect(response.headers['content-type']).to.equal('text/css');
done();
});

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ xdescribe('Scaffold Greenwood and Run Develop command: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});
});
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('application/json');
expect(response.headers['content-type']).to.equal('application/json; charset=utf-8');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Serve Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/html');
expect(response.headers['content-type']).to.equal('text/html');
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.contain('text/javascript');
expect(response.headers['content-type']).to.equal('text/javascript');
done();
});

Expand Down

0 comments on commit 1892226

Please sign in to comment.