mirror of
https://github.com/Kong/insomnia
synced 2024-11-12 17:26:32 +00:00
37 lines
937 B
JavaScript
37 lines
937 B
JavaScript
import getToken from '../grant-implicit';
|
|
import {createBWRedirectMock} from './helpers';
|
|
import {globalBeforeEach} from '../../../__jest__/before-each';
|
|
|
|
// Mock some test things
|
|
const AUTHORIZE_URL = 'https://foo.com/authorizeAuthCode';
|
|
const CLIENT_ID = 'client_123';
|
|
const REDIRECT_URI = 'https://foo.com/redirect';
|
|
const SCOPE = 'scope_123';
|
|
const STATE = 'state_123';
|
|
|
|
describe('implicit', () => {
|
|
beforeEach(globalBeforeEach);
|
|
it('works in default case', async () => {
|
|
createBWRedirectMock(`${REDIRECT_URI}#access_token=token_123&state=${STATE}&foo=bar`);
|
|
|
|
const result = await getToken(
|
|
AUTHORIZE_URL,
|
|
CLIENT_ID,
|
|
REDIRECT_URI,
|
|
SCOPE,
|
|
STATE
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
access_token: 'token_123',
|
|
token_type: null,
|
|
expires_in: null,
|
|
scope: null,
|
|
state: STATE,
|
|
error: null,
|
|
error_description: null,
|
|
error_uri: null
|
|
});
|
|
});
|
|
});
|