Skip to content

Commit c737b47

Browse files
committed
tests: add interceptor response shared tests
1 parent e2407f6 commit c737b47

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

test/test.authclient.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,24 @@ describe('AuthClient', () => {
4242
}
4343
});
4444

45-
describe('shared auth interceptor', () => {
46-
it('should use the default interceptor', () => {
45+
describe('shared auth interceptors', () => {
46+
it('should use the default interceptors', () => {
4747
const gaxios = new Gaxios();
4848

4949
new PassThroughClient({transporter: gaxios});
5050

5151
assert(
5252
gaxios.interceptors.request.has(AuthClient.DEFAULT_REQUEST_INTERCEPTOR),
5353
);
54+
assert(
55+
gaxios.interceptors.response.has(AuthClient.DEFAULT_RESPONSE_INTERCEPTOR),
56+
);
5457
});
5558

5659
it('should allow disabling of the default interceptor', () => {
5760
const gaxios = new Gaxios();
58-
const originalInterceptorCount = gaxios.interceptors.request.size;
61+
const originalRequestInterceptorCount = gaxios.interceptors.request.size;
62+
const originalResponseInterceptorCount = gaxios.interceptors.response.size;
5963

6064
const authClient = new PassThroughClient({
6165
transporter: gaxios,
@@ -65,19 +69,26 @@ describe('AuthClient', () => {
6569
assert.equal(authClient.transporter, gaxios);
6670
assert.equal(
6771
authClient.transporter.interceptors.request.size,
68-
originalInterceptorCount,
72+
originalRequestInterceptorCount,
73+
);
74+
assert.equal(
75+
authClient.transporter.interceptors.response.size,
76+
originalResponseInterceptorCount,
6977
);
7078
});
7179

7280
it('should add the default interceptor exactly once between instances', () => {
7381
const gaxios = new Gaxios();
74-
const originalInterceptorCount = gaxios.interceptors.request.size;
75-
const expectedInterceptorCount = originalInterceptorCount + 1;
82+
const originalRequestInterceptorCount = gaxios.interceptors.request.size;
83+
const expectedRequestInterceptorCount = originalRequestInterceptorCount + 1;
84+
const originalResponseInterceptorCount = gaxios.interceptors.response.size;
85+
const expectedResponseInterceptorCount = originalResponseInterceptorCount + 1;
7686

7787
new PassThroughClient({transporter: gaxios});
7888
new PassThroughClient({transporter: gaxios});
7989

80-
assert.equal(gaxios.interceptors.request.size, expectedInterceptorCount);
90+
assert.equal(gaxios.interceptors.request.size, expectedRequestInterceptorCount);
91+
assert.equal(gaxios.interceptors.response.size, expectedResponseInterceptorCount);
8192
});
8293

8394
describe('User-Agent', () => {

0 commit comments

Comments
 (0)