Skip to content

Commit

Permalink
added oauth tests to app.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed May 21, 2020
1 parent e8bd599 commit 893f706
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,61 @@ describe('App', () => {
assert(authorizeCallback.notCalled, 'Should not call the authorize callback on instantiation');
assert.instanceOf(app, App);
});
it('should fail without a token for single team authorization or authorize callback', async () => {
it('should fail without a token for single team authorization or authorize callback or oauth installer',
async () => {
// Arrange
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
new App({ signingSecret: '' }); // tslint:disable-line:no-unused-expression
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
}
});
it('should fail when both a token and authorize callback are specified', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
new App({ signingSecret: '' }); // tslint:disable-line:no-unused-expression
// tslint:disable-next-line:no-unused-expression
new App({ token: '', authorize: authorizeCallback, signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
assert(authorizeCallback.notCalled);
}
});
it('should fail when both a token and authorize callback are specified', async () => {
it('should fail when both a token is specified and OAuthInstaller is initialized', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
// tslint:disable-next-line:no-unused-expression
new App({ token: '', authorize: authorizeCallback, signingSecret: '' });
new App({ token: '', clientId: '', clientSecret: '', stateSecret: '', signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
assert(authorizeCallback.notCalled);
}
});
it('should fail when both a authorize callback is specified and OAuthInstaller is initialized', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
// tslint:disable-next-line:no-unused-expression
new App({ authorize: authorizeCallback, clientId: '', clientSecret: '', stateSecret: '', signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
Expand Down

0 comments on commit 893f706

Please sign in to comment.