insomnia/app/network/o-auth-2/__tests__/grant-implicit.test.js
2017-07-19 20:36:44 -07:00

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
});
});
});