Skip to content

Commit f3af175

Browse files
merlinnotthechenky
authored andcommitted
Include all TypeScript files in development configuration (#512)
* Include all TypeScript files in development configuration * Autofix TSLint issues * Reformat
1 parent 59adaa8 commit f3af175

File tree

10 files changed

+27
-29
lines changed

10 files changed

+27
-29
lines changed

integration_test/functions/src/auth-tests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq } from './testing';
31
import * as admin from 'firebase-admin';
2+
import * as functions from 'firebase-functions';
3+
import { expectEq, TestSuite } from './testing';
44
import UserMetadata = admin.auth.UserRecord;
55

66
export const createUserTests: any = functions.auth.user().onCreate((u, c) => {
7-
let testId: string = u.displayName;
7+
const testId: string = u.displayName;
88
console.log(`testId is ${testId}`);
99

1010
return new TestSuite<UserMetadata>('auth user onCreate')
@@ -38,7 +38,7 @@ export const createUserTests: any = functions.auth.user().onCreate((u, c) => {
3838
});
3939

4040
export const deleteUserTests: any = functions.auth.user().onDelete((u, c) => {
41-
let testId: string = u.displayName;
41+
const testId: string = u.displayName;
4242
console.log(`testId is ${testId}`);
4343

4444
return new TestSuite<UserMetadata>('auth user onDelete')

integration_test/functions/src/database-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq, expectMatches } from './testing';
31
import * as admin from 'firebase-admin';
2+
import * as functions from 'firebase-functions';
3+
import { expectEq, expectMatches, TestSuite } from './testing';
44
import DataSnapshot = admin.database.DataSnapshot;
55

66
const testIdFieldName = 'testId';

integration_test/functions/src/firestore-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq, expectDeepEq } from './testing';
31
import * as admin from 'firebase-admin';
2+
import * as functions from 'firebase-functions';
3+
import { expectDeepEq, expectEq, TestSuite } from './testing';
44
import DocumentSnapshot = admin.firestore.DocumentSnapshot;
55

66
const testIdFieldName = 'documentId';

integration_test/functions/src/https-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as functions from 'firebase-functions';
22
import * as _ from 'lodash';
3-
import { TestSuite, expectEq } from './testing';
3+
import { expectEq, TestSuite } from './testing';
44

55
export const callableTests: any = functions.https.onCall((d) => {
66
return new TestSuite('https onCall')

integration_test/functions/src/index.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import * as functions from 'firebase-functions';
2-
import * as https from 'https';
3-
import * as admin from 'firebase-admin';
41
import { Request, Response } from 'express';
2+
import * as admin from 'firebase-admin';
3+
import * as functions from 'firebase-functions';
54
import * as fs from 'fs';
6-
7-
import * as PubSub from '@google-cloud/pubsub';
8-
const pubsub = PubSub();
5+
import * as https from 'https';
96

107
export * from './pubsub-tests';
118
export * from './database-tests';
@@ -82,7 +79,7 @@ export const integrationTests: any = functions
8279
.split('.')
8380
.slice(1)
8481
.join('.');
85-
let pubsub: any = require('@google-cloud/pubsub')();
82+
const pubsub: any = require('@google-cloud/pubsub')();
8683
const testId = admin
8784
.database()
8885
.ref()
@@ -155,7 +152,7 @@ export const integrationTests: any = functions
155152
.then(() => {
156153
// On test completion, check that all tests pass and reply "PASS", or provide further details.
157154
console.log('Waiting for all tests to report they pass...');
158-
let ref = admin.database().ref(`testRuns/${testId}`);
155+
const ref = admin.database().ref(`testRuns/${testId}`);
159156
return new Promise((resolve, reject) => {
160157
let testsExecuted = 0;
161158
ref.on('child_added', (snapshot) => {

integration_test/functions/src/pubsub-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as functions from 'firebase-functions';
21
import * as admin from 'firebase-admin';
3-
import { TestSuite, expectEq, evaluate, success } from './testing';
2+
import * as functions from 'firebase-functions';
3+
import { evaluate, expectEq, success, TestSuite } from './testing';
44
import PubsubMessage = functions.pubsub.Message;
55

66
// TODO(inlined) use multiple queues to run inline.
@@ -64,7 +64,7 @@ export const schedule: any = functions.pubsub
6464
// For the test, the job is triggered by the jobs:run api
6565
.onRun((context) => {
6666
let testId;
67-
let db = admin.database();
67+
const db = admin.database();
6868
return new Promise(async (resolve, reject) => {
6969
await db
7070
.ref('testRuns')

integration_test/functions/src/remoteConfig-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq } from './testing';
2+
import { expectEq, TestSuite } from './testing';
33
import TemplateVersion = functions.remoteConfig.TemplateVersion;
44

55
export const remoteConfigTests: any = functions.remoteConfig.onUpdate(

integration_test/functions/src/storage-tests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as functions from 'firebase-functions';
2-
import { TestSuite, expectEq, expectDeepEq } from './testing';
2+
import { expectEq, TestSuite } from './testing';
33
import ObjectMetadata = functions.storage.ObjectMetadata;
4-
const testIdFieldName = 'documentId';
54

65
export const storageTests: any = functions
76
.runWith({

integration_test/functions/src/testing.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as firebase from 'firebase-admin';
2-
import * as _ from 'lodash';
32
import { EventContext } from 'firebase-functions';
3+
import * as _ from 'lodash';
44

55
export type TestCase<T> = (data: T, context?: EventContext) => any;
6-
export type TestCaseMap<T> = { [key: string]: TestCase<T> };
6+
export interface TestCaseMap<T> {
7+
[key: string]: TestCase<T>;
8+
}
79

810
export class TestSuite<T> {
911
private name: string;
@@ -20,8 +22,8 @@ export class TestSuite<T> {
2022
}
2123

2224
run(testId: string, data: T, context?: EventContext): Promise<any> {
23-
let running: Array<Promise<any>> = [];
24-
for (let testName in this.tests) {
25+
const running: Array<Promise<any>> = [];
26+
for (const testName in this.tests) {
2527
if (!this.tests.hasOwnProperty(testName)) {
2628
continue;
2729
}
@@ -36,7 +38,7 @@ export class TestSuite<T> {
3638
},
3739
(error) => {
3840
console.error(`Failed: ${testName}`, error);
39-
return { name: testName, passed: 0, error: error };
41+
return { name: testName, passed: 0, error };
4042
}
4143
);
4244
running.push(run);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"sourceMap": true
55
},
66
"extends": "./tsconfig.release.json",
7-
"include": ["./src/**/*.ts", "./spec/**/*.ts"]
7+
"include": ["**/*.ts"]
88
}

0 commit comments

Comments
 (0)