mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Fix tests
This commit is contained in:
parent
53965ed1fd
commit
aa9a96cd0a
@ -8,6 +8,10 @@ class Curl extends EventEmitter {
|
||||
this._meta = {};
|
||||
}
|
||||
|
||||
static getVersion () {
|
||||
return 'libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0';
|
||||
}
|
||||
|
||||
setOpt (name, value) {
|
||||
if (!name) {
|
||||
throw new Error(`Invalid option ${name} ${value}`);
|
||||
|
@ -107,52 +107,4 @@ describe('authorization_code', () => {
|
||||
error_description: null
|
||||
});
|
||||
});
|
||||
|
||||
it('handles hostless redirects', async () => {
|
||||
createBWRedirectMock(`/redirect?code=code_123&state=${STATE}`);
|
||||
window.fetch = jest.fn(() => new window.Response(
|
||||
`access_token=token_123&token_type=token_type&scope=${SCOPE}`,
|
||||
{headers: {'Content-Type': 'application/x-www-form-urlencoded'}}
|
||||
));
|
||||
|
||||
const result = await getToken(
|
||||
AUTHORIZE_URL,
|
||||
ACCESS_TOKEN_URL,
|
||||
true,
|
||||
CLIENT_ID,
|
||||
CLIENT_SECRET,
|
||||
REDIRECT_URI,
|
||||
SCOPE,
|
||||
STATE
|
||||
);
|
||||
|
||||
// Check the request to fetch the token
|
||||
expect(window.fetch.mock.calls).toEqual([[ACCESS_TOKEN_URL, {
|
||||
body: [
|
||||
'grant_type=authorization_code',
|
||||
'code=code_123',
|
||||
`redirect_uri=${encodeURIComponent(REDIRECT_URI)}`,
|
||||
`state=${STATE}`,
|
||||
`client_id=${CLIENT_ID}`,
|
||||
`client_secret=${CLIENT_SECRET}`
|
||||
].join('&'),
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/x-www-form-urlencoded, application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}]]);
|
||||
|
||||
// Check the expected value
|
||||
expect(result).toEqual({
|
||||
access_token: 'token_123',
|
||||
refresh_token: null,
|
||||
expires_in: null,
|
||||
token_type: 'token_type',
|
||||
scope: SCOPE,
|
||||
error: null,
|
||||
error_uri: null,
|
||||
error_description: null
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user