Skip to content

Commit

Permalink
fix: update code to support typescript@2.6.2 (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored and ofrobots committed Jan 9, 2018
1 parent 0cd813c commit b917e5d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions test/test.oauth2.ts
Expand Up @@ -17,6 +17,7 @@
import * as assert from 'assert';
import {AxiosRequestConfig} from 'axios';
import * as crypto from 'crypto';
import {randomBytes} from 'crypto';
import * as fs from 'fs';
import * as nock from 'nock';
import * as path from 'path';
Expand Down Expand Up @@ -46,8 +47,10 @@ describe('OAuth2 client', () => {
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
const generated = oauth2client.generateAuthUrl(opts);
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);

assert.equal(query.response_type, 'code token');
assert.equal(query.access_type, ACCESS_TYPE);
assert.equal(query.scope, SCOPE);
Expand All @@ -67,8 +70,10 @@ describe('OAuth2 client', () => {
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
const generated = oauth2client.generateAuthUrl(opts);
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);

assert.equal(query.scope, SCOPE_ARRAY.join(' '));
done();
});
Expand All @@ -80,8 +85,10 @@ describe('OAuth2 client', () => {
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
const generated = oauth2client.generateAuthUrl();
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);

assert.equal(query.response_type, 'code');
done();
});
Expand Down Expand Up @@ -793,6 +800,9 @@ describe('OAuth2 client', () => {
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
const generated = oauth2client.generateAuthUrl({});
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);
assert.equal(query.redirect_uri, REDIRECT_URI);
});
Expand All @@ -802,6 +812,9 @@ describe('OAuth2 client', () => {
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
const generated = oauth2client.generateAuthUrl({});
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);
assert.equal(query.client_id, CLIENT_ID);
});
Expand All @@ -812,6 +825,9 @@ describe('OAuth2 client', () => {
const generated =
oauth2client.generateAuthUrl({redirect_uri: 'overridden'});
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);
assert.equal(query.redirect_uri, 'overridden');
});
Expand All @@ -822,6 +838,9 @@ describe('OAuth2 client', () => {
const generated =
oauth2client.generateAuthUrl({client_id: 'client_override'});
const parsed = url.parse(generated);
if (typeof parsed.query !== 'string') {
throw new Error('Unable to parse querystring');
}
const query = qs.parse(parsed.query);
assert.equal(query.client_id, 'client_override');
});
Expand Down

0 comments on commit b917e5d

Please sign in to comment.