Skip to content

Commit fdebc53

Browse files
arun3528sreenara
authored andcommitted
fix: add server for mocha test (#3)
1 parent 96b207c commit fdebc53

File tree

6 files changed

+40
-36
lines changed

6 files changed

+40
-36
lines changed

packages/@webex/webex-core/test/integration/spec/services/services.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,22 @@ describe('webex-core', () => {
4242
})
4343
);
4444

45-
beforeEach('create webex instance', async () => {
45+
beforeEach('create webex instance', () => {
4646
webex = new WebexCore({credentials: {supertoken: webexUser.token}});
4747
webexEU = new WebexCore({credentials: {supertoken: webexUserEU.token}});
4848
services = webex.internal.services;
4949
servicesEU = webexEU.internal.services;
5050
catalog = services._getCatalog();
5151

52-
await Promise.all([
52+
return Promise.all([
5353
services.waitForCatalog('postauth', 10),
5454
servicesEU.waitForCatalog('postauth', 10),
55-
]);
56-
await services.updateServices({
57-
from: 'limited',
58-
query: {userId: webexUser.id},
59-
})
55+
]).then(() =>
56+
services.updateServices({
57+
from: 'limited',
58+
query: {userId: webexUser.id},
59+
})
60+
);
6061
});
6162

6263
describe('#_getCatalog()', () => {
@@ -86,14 +87,14 @@ describe('webex-core', () => {
8687
let testUrlTemplate;
8788
let testUrl;
8889

89-
beforeEach('load test url', async () => {
90+
beforeEach('load test url', () => {
9091
testUrlTemplate = {
9192
defaultUrl: 'https://www.example.com/api/v1',
9293
hosts: [],
9394
name: 'exampleValid',
9495
};
9596
testUrl = new ServiceUrl(testUrlTemplate);
96-
await catalog._loadServiceUrls('preauth', [testUrl]);
97+
catalog._loadServiceUrls('preauth', [testUrl]);
9798
});
9899

99100
afterEach('unload test url', () => {
@@ -531,7 +532,7 @@ describe('webex-core', () => {
531532
let testUrl;
532533
let testUrlTemplate;
533534

534-
beforeEach('load test url', async () => {
535+
beforeEach('load test url', () => {
535536
testUrlTemplate = {
536537
defaultUrl: 'https://www.example.com/api/v1',
537538
hosts: [
@@ -552,7 +553,7 @@ describe('webex-core', () => {
552553
name: 'exampleValid',
553554
};
554555
testUrl = new ServiceUrl(testUrlTemplate);
555-
await catalog._loadServiceUrls('preauth', [testUrl]);
556+
catalog._loadServiceUrls('preauth', [testUrl]);
556557
});
557558

558559
it('converts the url to a priority host url', () => {
@@ -733,15 +734,18 @@ describe('webex-core', () => {
733734
done();
734735
});
735736
});
736-
it('updates the limited catalog when query param mode is provided', async () => {
737+
it('updates the limited catalog when query param mode is provided', (done) => {
737738
catalog.serviceGroups.preauth = [];
738739

739-
await services
740+
services
740741
.updateServices({
741742
from: 'limited',
742743
query: {mode: 'DEFAULT_BY_PROXIMITY'},
744+
})
745+
.then(() => {
746+
assert.isAbove(catalog.serviceGroups.preauth.length, 0);
747+
done();
743748
});
744-
assert.isAbove(catalog.serviceGroups.preauth.length, 0);
745749
});
746750
it('does not update the limited catalog when nothing is provided', () => {
747751
catalog.serviceGroups.preauth = [];
@@ -789,12 +793,11 @@ describe('webex-core', () => {
789793
});
790794

791795
describe('#fetchClientRegionInfo()', () => {
792-
it('returns client region info', async () => {
796+
it('returns client region info', () =>
793797
services.fetchClientRegionInfo().then((r) => {
794798
assert.isDefined(r.countryCode);
795799
assert.isDefined(r.timezone);
796-
})
797-
});
800+
}));
798801
});
799802

800803
describe('#validateUser()', () => {
@@ -867,21 +870,21 @@ describe('webex-core', () => {
867870
assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
868871
}));
869872

870-
it('validates new user with activationOptions suppressEmail false', async () => {
871-
const r = await unauthServices
873+
it('validates new user with activationOptions suppressEmail false', () =>
874+
unauthServices
872875
.validateUser({
873876
email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`,
874877
activationOptions: {suppressEmail: false},
875-
});
876-
877-
assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
878-
assert.equal(r.activated, false);
879-
assert.equal(r.exists, false);
880-
assert.equal(r.user.verificationEmailTriggered, true);
881-
assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
882-
assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
883-
assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
884-
});
878+
})
879+
.then((r) => {
880+
assert.hasAllKeys(r, ['activated', 'exists', 'user', 'details']);
881+
assert.equal(r.activated, false);
882+
assert.equal(r.exists, false);
883+
assert.equal(r.user.verificationEmailTriggered, true);
884+
assert.isAbove(Object.keys(unauthServices.list(false, 'preauth')).length, 0);
885+
assert.equal(Object.keys(unauthServices.list(false, 'signin')).length, 0);
886+
assert.equal(Object.keys(unauthServices.list(false, 'postauth')).length, 0);
887+
}));
885888

886889
it('validates new user with activationOptions suppressEmail true', () =>
887890
unauthServices

packages/@webex/webex-core/test/integration/spec/webex-core.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('webex-core', function () {
1717
webex = new WebexCore();
1818
});
1919

20-
it.skip('adds a tracking id to each request', () =>
20+
it('adds a tracking id to each request', () =>
2121
webex
2222
.request({
2323
uri: makeLocalUrl('/'),
@@ -35,7 +35,7 @@ describe('webex-core', function () {
3535
);
3636
}));
3737

38-
it.skip('adds a spark-user-agent id to each request', () =>
38+
it('adds a spark-user-agent id to each request', () =>
3939
webex
4040
.request({
4141
uri: makeLocalUrl('/'),
@@ -47,7 +47,7 @@ describe('webex-core', function () {
4747
assert.property(res.options.headers, 'spark-user-agent');
4848
}));
4949

50-
it.skip('fails with a WebexHttpError', () =>
50+
it('fails with a WebexHttpError', () =>
5151
assert
5252
.isRejected(
5353
webex.request({

packages/legacy/tools/src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Karma from './karma';
33
import {
44
startServer,
55
stopServer,
6-
} from './karma/server';
6+
} from './server';
77
import Mocha from './mocha';
88

99
export {

packages/legacy/tools/src/utils/karma/karma.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import '@babel/register';
22
import '@webex/env-config-legacy';
33

44
import KarmaRunner from 'karma';
5-
import { startServer, stopServer } from './server';
5+
import { startServer, stopServer } from '../server';
66

77
import Browsers from './browsers';
88

packages/legacy/tools/src/utils/mocha/mocha.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Babel from '@babel/register';
22
import '@webex/env-config-legacy';
3-
43
import MochaRunner from 'mocha';
4+
import { startServer, stopServer } from '../server';
55

66
import CONSTANTS from './mocha.constants';
77

@@ -31,11 +31,12 @@ class Mocha {
3131
files.forEach((file) => mochaRunner.addFile(file));
3232

3333
return new Promise((resolve) => {
34+
startServer();
3435
mochaRunner.run((failures) => {
3536
if (failures !== 0) {
3637
process.exit(1);
3738
}
38-
39+
stopServer();
3940
resolve(undefined);
4041
});
4142
});
File renamed without changes.

0 commit comments

Comments
 (0)