Skip to content

Commit

Permalink
Fix TS compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Aug 29, 2022
1 parent 4d12bbd commit d24e319
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ test('cookies are cleared when redirecting to a different hostname (no cookieJar
cookie: 'foo=bar',
'user-agent': 'custom',
},
}).json();
}).json<{headers: Record<string, string | undefined>}>();
t.is(headers.Cookie, undefined);
t.is(headers['User-Agent'], 'custom');
});
2 changes: 1 addition & 1 deletion test/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ test('waits for handlers to finish', withServer, async (t, server, got) => {
],
});

const {foo} = await instance('').json();
const {foo} = await instance('').json<{foo: 'bar'}>();
t.is(foo, 'bar');
});

Expand Down
4 changes: 2 additions & 2 deletions test/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ test('strip port in host header if implicit standard port & protocol (HTTPS)', a
test('correctly encodes authorization header', withServer, async (t, server, got) => {
server.get('/', echoHeaders);

const {authorization} = await got('', {username: 'test@'}).json();
const {authorization} = await got('', {username: 'test@'}).json<{authorization: string}>();

t.is(authorization, `Basic ${Buffer.from('test@:').toString('base64')}`);
});

test('url passes if credentials contain special characters', withServer, async (t, server, got) => {
server.get('/', echoHeaders);

const {authorization} = await got('', {password: 't$es%t'}).json();
const {authorization} = await got('', {password: 't$es%t'}).json<{authorization: string}>();

t.is(authorization, `Basic ${Buffer.from(':t$es%t').toString('base64')}`);
});
4 changes: 2 additions & 2 deletions test/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ test('clears username and password when redirecting to a different hostname', wi
const {headers} = await got('', {
username: 'hello',
password: 'world',
}).json();
}).json<{headers: Record<string, string | undefined>}>();
t.is(headers.Authorization, undefined);
});

Expand All @@ -506,7 +506,7 @@ test('clears the authorization header when redirecting to a different hostname',
headers: {
authorization: 'Basic aGVsbG86d29ybGQ=',
},
}).json();
}).json<{headers: Record<string, string | undefined>}>();
t.is(headers.Authorization, undefined);
});

Expand Down
4 changes: 2 additions & 2 deletions test/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,9 @@ test('reuses request options on retry', withServer, async (t, server, got) => {
response.end(JSON.stringify(request.headers));
});

const {body: {accept}, retryCount} = await got('', {timeout: {request: 1000}, responseType: 'json'});
const {body, retryCount} = await got('', {timeout: {request: 1000}, responseType: 'json'});
t.is(retryCount, 1);
t.is(accept, 'application/json');
t.is((body as any).accept, 'application/json');
});

test('respects backoffLimit', withServer, async (t, server, got) => {
Expand Down

0 comments on commit d24e319

Please sign in to comment.