Skip to content

Commit e323792

Browse files
authored
Merge pull request #212 from AthennaIO/develop
feat: add authorize method to test request
2 parents 1172345 + c2c3b20 commit e323792

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/http",
3-
"version": "5.26.0",
3+
"version": "5.27.0",
44
"description": "The Athenna Http server. Built on top of fastify.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/testing/plugins/request/TestRequest.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ export class TestRequest extends Macroable {
4545
url: string,
4646
options: InjectOptions = {}
4747
): Promise<TestResponse> {
48+
options.headers = {
49+
...this.headers,
50+
...options.headers
51+
}
52+
4853
return Server.request({
4954
url,
5055
method: 'GET',
51-
...this.headers,
5256
...options
5357
}).then(res => this.createResponse(res))
5458
}
@@ -67,10 +71,14 @@ export class TestRequest extends Macroable {
6771
url: string,
6872
options: InjectOptions = {}
6973
): Promise<TestResponse> {
74+
options.headers = {
75+
...this.headers,
76+
...options.headers
77+
}
78+
7079
return Server.request({
7180
url,
7281
method: 'HEAD',
73-
...this.headers,
7482
...options
7583
}).then(res => this.createResponse(res))
7684
}
@@ -89,10 +97,14 @@ export class TestRequest extends Macroable {
8997
url: string,
9098
options: InjectOptions = {}
9199
): Promise<TestResponse> {
100+
options.headers = {
101+
...this.headers,
102+
...options.headers
103+
}
104+
92105
return Server.request({
93106
url,
94107
method: 'OPTIONS',
95-
...this.headers,
96108
...options
97109
}).then(res => this.createResponse(res))
98110
}
@@ -111,10 +123,14 @@ export class TestRequest extends Macroable {
111123
url: string,
112124
options: InjectOptions = {}
113125
): Promise<TestResponse> {
126+
options.headers = {
127+
...this.headers,
128+
...options.headers
129+
}
130+
114131
return Server.request({
115132
url,
116133
method: 'POST',
117-
...this.headers,
118134
...options
119135
}).then(res => this.createResponse(res))
120136
}
@@ -133,10 +149,14 @@ export class TestRequest extends Macroable {
133149
url: string,
134150
options: InjectOptions = {}
135151
): Promise<TestResponse> {
152+
options.headers = {
153+
...this.headers,
154+
...options.headers
155+
}
156+
136157
return Server.request({
137158
url,
138159
method: 'PUT',
139-
...this.headers,
140160
...options
141161
}).then(res => this.createResponse(res))
142162
}
@@ -155,10 +175,14 @@ export class TestRequest extends Macroable {
155175
url: string,
156176
options: InjectOptions = {}
157177
): Promise<TestResponse> {
178+
options.headers = {
179+
...this.headers,
180+
...options.headers
181+
}
182+
158183
return Server.request({
159184
url,
160185
method: 'PATCH',
161-
...this.headers,
162186
...options
163187
}).then(res => this.createResponse(res))
164188
}
@@ -177,10 +201,14 @@ export class TestRequest extends Macroable {
177201
url: string,
178202
options: InjectOptions = {}
179203
): Promise<TestResponse> {
204+
options.headers = {
205+
...this.headers,
206+
...options.headers
207+
}
208+
180209
return Server.request({
181210
url,
182211
method: 'DELETE',
183-
...this.headers,
184212
...options
185213
}).then(res => this.createResponse(res))
186214
}

0 commit comments

Comments
 (0)