Skip to content

Commit

Permalink
Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz committed Jun 1, 2019
1 parent e4c89a6 commit e980112
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/o365/aad/AadCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AadCommand from './AadCommand';
import auth from './AadAuth';
import Utils from '../../Utils';
import { CommandError } from '../../Command';
import appInsights from '../../appInsights';

class MockCommand extends AadCommand {
public get name(): string {
Expand All @@ -22,6 +23,14 @@ class MockCommand extends AadCommand {
}

describe('AadCommand', () => {
before(() => {
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

after(() => {
Utils.restore(appInsights.trackEvent);
});

it('correctly reports an error while restoring auth info', (done) => {
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.reject('An error has occurred'));
const command = new MockCommand();
Expand Down
9 changes: 9 additions & 0 deletions src/o365/azmgmt/AzmgmtCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AzmgmtCommand from './AzmgmtCommand';
import auth from './AzmgmtAuth';
import Utils from '../../Utils';
import { CommandError } from '../../Command';
import appInsights from '../../appInsights';

class MockCommand extends AzmgmtCommand {
public get name(): string {
Expand All @@ -22,6 +23,14 @@ class MockCommand extends AzmgmtCommand {
}

describe('AzmgmtCommand', () => {
before(() => {
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

after(() => {
Utils.restore(appInsights.trackEvent);
});

it('correctly reports an error while restoring auth info', (done) => {
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.reject('An error has occurred'));
const command = new MockCommand();
Expand Down
8 changes: 7 additions & 1 deletion src/o365/spo/SpoCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import auth, { Site } from './SpoAuth';
import Utils from '../../Utils';
import { CommandError } from '../../Command';
import { FormDigestInfo } from './spo';
import appInsights from '../../appInsights';

class MockCommand extends SpoCommand {
public get name(): string {
Expand All @@ -28,6 +29,10 @@ describe('SpoCommand', () => {
let cmdInstance: any;
let log: string[];

before(() => {
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

beforeEach(() => {
log = [];
cmdInstance = {
Expand All @@ -49,7 +54,8 @@ describe('SpoCommand', () => {
Utils.restore([
request.post,
auth.ensureAccessToken,
auth.restoreAuth
auth.restoreAuth,
appInsights.trackEvent
]);
});

Expand Down
5 changes: 4 additions & 1 deletion src/o365/spo/commands/orgnewssite/orgnewssite-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const command: Command = require('./orgnewssite-list');
import * as assert from 'assert';
import request from '../../../../request';
import Utils from '../../../../Utils';
import appInsights from '../../../../appInsights';

describe(commands.ORGNEWSSITE_LIST, () => {
let vorpal: Vorpal;
Expand All @@ -16,6 +17,7 @@ describe(commands.ORGNEWSSITE_LIST, () => {
before(() => {
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.resolve());
sinon.stub(auth, 'ensureAccessToken').callsFake(() => { return Promise.resolve('ABC'); });
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

beforeEach(() => {
Expand All @@ -41,7 +43,8 @@ describe(commands.ORGNEWSSITE_LIST, () => {
Utils.restore([
auth.ensureAccessToken,
auth.restoreAuth,
request.post
request.post,
appInsights.trackEvent
]);
});

Expand Down
5 changes: 4 additions & 1 deletion src/o365/spo/commands/orgnewssite/orgnewssite-remove.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const command: Command = require('./orgnewssite-remove');
import * as assert from 'assert';
import request from '../../../../request';
import Utils from '../../../../Utils';
import appInsights from '../../../../appInsights';

describe(commands.ORGNEWSSITE_REMOVE, () => {
let vorpal: Vorpal;
Expand All @@ -17,6 +18,7 @@ describe(commands.ORGNEWSSITE_REMOVE, () => {
before(() => {
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.resolve());
sinon.stub(auth, 'ensureAccessToken').callsFake(() => { return Promise.resolve('ABC'); });
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

beforeEach(() => {
Expand Down Expand Up @@ -47,7 +49,8 @@ describe(commands.ORGNEWSSITE_REMOVE, () => {
Utils.restore([
auth.ensureAccessToken,
auth.restoreAuth,
request.post
request.post,
appInsights.trackEvent
]);
});

Expand Down
5 changes: 4 additions & 1 deletion src/o365/spo/commands/orgnewssite/orgnewssite-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const command: Command = require('./orgnewssite-set');
import * as assert from 'assert';
import request from '../../../../request';
import Utils from '../../../../Utils';
import appInsights from '../../../../appInsights';

describe(commands.ORGNEWSSITE_SET, () => {
let vorpal: Vorpal;
Expand All @@ -16,6 +17,7 @@ describe(commands.ORGNEWSSITE_SET, () => {
before(() => {
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.resolve());
sinon.stub(auth, 'ensureAccessToken').callsFake(() => { return Promise.resolve('ABC'); });
sinon.stub(appInsights, 'trackEvent').callsFake(() => {});
});

beforeEach(() => {
Expand All @@ -41,7 +43,8 @@ describe(commands.ORGNEWSSITE_SET, () => {
Utils.restore([
auth.ensureAccessToken,
auth.restoreAuth,
request.post
request.post,
appInsights.trackEvent
]);
});

Expand Down

0 comments on commit e980112

Please sign in to comment.