Skip to content

Commit 63044f0

Browse files
authored
Upgraded Mocha to 5.x (#345)
* Upgraded Mocha to 5.x * Implemented app clean up after tests * Fixing a typo
1 parent 4179dd3 commit 63044f0

File tree

4 files changed

+62
-172
lines changed

4 files changed

+62
-172
lines changed

package-lock.json

Lines changed: 43 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"lint": "run-p lint:src lint:unit lint:integration",
1414
"test": "run-s lint test:unit",
1515
"integration": "run-s build test:integration",
16-
"test:unit": "mocha test/unit/*.spec.ts --compilers ts:ts-node/register",
17-
"test:integration": "mocha test/integration/*.ts --slow 5000 --timeout 5000 --compilers ts:ts-node/register",
16+
"test:unit": "mocha test/unit/*.spec.ts --require ts-node/register",
17+
"test:integration": "mocha test/integration/*.ts --slow 5000 --timeout 5000 --require ts-node/register",
1818
"test:coverage": "nyc npm run test:unit",
1919
"lint:src": "tslint --format stylish -p tsconfig.json",
2020
"lint:unit": "tslint -c tslint-test.json --format stylish test/unit/*.ts test/unit/**/*.ts",
@@ -85,14 +85,13 @@
8585
"gulp-exit": "0.0.2",
8686
"gulp-header": "^1.8.8",
8787
"gulp-istanbul": "^1.1.3",
88-
"gulp-mocha": "^3.0.1",
8988
"gulp-replace": "^0.5.4",
9089
"gulp-tslint": "^6.0.2",
9190
"gulp-typescript": "^3.2.4",
9291
"lodash": "^4.17.5",
9392
"merge2": "^1.2.1",
9493
"minimist": "^1.2.0",
95-
"mocha": "^3.5.0",
94+
"mocha": "^5.2.0",
9695
"nock": "^9.1.8",
9796
"npm-run-all": "^4.1.2",
9897
"nyc": "^11.5.0",

test/integration/database.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@ describe('admin.database', () => {
4343
}
4444
console.log(chalk.yellow(' Updating security rules to defaults.'));
4545
/* tslint:enable:no-console */
46-
const client = new apiRequest.SignedApiRequestHandler(defaultApp);
46+
const client = new apiRequest.AuthorizedHttpClient(defaultApp);
4747
const dbUrl = url.parse(databaseUrl);
4848
const defaultRules = {
4949
rules : {
5050
'.read': 'auth != null',
5151
'.write': 'auth != null',
5252
},
5353
};
54-
const headers = {
55-
'Content-Type': 'application/json',
56-
};
57-
return client.sendRequest(dbUrl.host, 443, '/.settings/rules.json',
58-
'PUT', defaultRules, headers, 10000);
54+
return client.send({
55+
url: `https://${dbUrl.host}/.settings/rules.json`,
56+
method: 'PUT',
57+
data: defaultRules,
58+
timeout: 10000,
59+
});
5960
});
6061

6162
it('admin.database() returns a database client', () => {

test/integration/setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ before(() => {
9898
cmdArgs = minimist(process.argv.slice(2));
9999
});
100100

101+
after(() => {
102+
return Promise.all([
103+
defaultApp.delete(),
104+
nullApp.delete(),
105+
nonNullApp.delete(),
106+
noServiceAccountApp.delete(),
107+
]);
108+
});
109+
101110
class CertificatelessCredential implements Credential {
102111
private readonly delegate: admin.credential.Credential;
103112

0 commit comments

Comments
 (0)