Skip to content

Commit 01a3502

Browse files
committed
Clean up unit tests
1 parent 7250470 commit 01a3502

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

test/common/app.common.ts

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export function routes(app) {
123123
res.json({
124124
...req.body,
125125
contentType: req.headers['content-type'],
126-
accept: req.headers['accept'],
127126
id: 'new-id',
128127
});
129128
});

test/headers.spec.ts

+24-13
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe(packageJson.name, () => {
7171
})
7272
.expect(200));
7373

74-
it('should succeed in sending a content-type: "application/json; version=1"', async () =>
75-
request(app)
74+
it('should succeed in sending a content-type: "application/json; version=1" in multiple ways', async () =>{
75+
await request(app)
7676
.post(`${app.basePath}/pets_content_types`)
7777
.set('Content-Type', 'application/json; version=1')
7878
.set('Accept', 'application/json')
@@ -83,9 +83,22 @@ describe(packageJson.name, () => {
8383
.expect(200)
8484
.expect((res) => {
8585
expect(res.body.contentType).to.equal('application/json; version=1')
86-
})
87-
);
86+
});
8887

88+
await request(app)
89+
.post(`${app.basePath}/pets_content_types`)
90+
.set('Content-Type', 'application/json;version=1')
91+
.set('Accept', 'application/json')
92+
.send({
93+
name: 'myPet',
94+
tag: 'cat',
95+
})
96+
.expect(200)
97+
.expect((res) => {
98+
expect(res.body.contentType).to.equal('application/json;version=1')
99+
});
100+
});
101+
89102
it('should throw a 415 error for unsupported "application/json; version=2" content type', async () =>
90103
request(app)
91104
.post(`${app.basePath}/pets_content_types`)
@@ -97,8 +110,8 @@ describe(packageJson.name, () => {
97110
})
98111
.expect(415));
99112

100-
it('should succeed in sending a content-type: "application/json;version=1', async () =>
101-
request(app)
113+
it('should throw a 415 error for a path/method which has previously succeeded using different request body content types', async () => {
114+
await request(app)
102115
.post(`${app.basePath}/pets_content_types`)
103116
.set('Content-Type', 'application/json;version=1')
104117
.set('Accept', 'application/json')
@@ -109,19 +122,17 @@ describe(packageJson.name, () => {
109122
.expect(200)
110123
.expect((res) => {
111124
expect(res.body.contentType).to.equal('application/json;version=1')
112-
})
113-
);
114-
115-
it('should throw a 415 error for a path/method that\'s already been cached', async () =>
116-
request(app)
125+
});
126+
127+
await request(app)
117128
.post(`${app.basePath}/pets_content_types`)
118129
.set('Content-Type', 'application/json; version=3')
119130
.set('Accept', 'application/json')
120131
.send({
121132
name: 'myPet',
122133
tag: 'cat',
123134
})
124-
.expect(415));
125-
135+
.expect(415);
136+
});
126137
});
127138
});

0 commit comments

Comments
 (0)