Skip to content

Commit 2cc54d1

Browse files
committed
Fix another set of eslint issues.
1 parent b6c7504 commit 2cc54d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3353
-4381
lines changed
Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectEq, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectEq, TestSuite } from "../testing";
55
import UserMetadata = admin.auth.UserRecord;
66

77
export const createUserTests: any = functions
@@ -11,35 +11,26 @@ export const createUserTests: any = functions
1111
const testId: string = u.displayName;
1212
functions.logger.info(`testId is ${testId}`);
1313

14-
return new TestSuite<UserMetadata>('auth user onCreate')
15-
.it('should have a project as resource', (user, context) =>
16-
expectEq(
17-
context.resource.name,
18-
`projects/${process.env.GCLOUD_PROJECT}`
19-
)
14+
return new TestSuite<UserMetadata>("auth user onCreate")
15+
.it("should have a project as resource", (user, context) =>
16+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
2017
)
2118

22-
.it('should not have a path', (user, context) =>
23-
expectEq((context as any).path, undefined)
24-
)
19+
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
2520

26-
.it('should have the correct eventType', (user, context) =>
27-
expectEq(context.eventType, 'google.firebase.auth.user.create')
21+
.it("should have the correct eventType", (user, context) =>
22+
expectEq(context.eventType, "google.firebase.auth.user.create")
2823
)
2924

30-
.it('should have an eventId', (user, context) => context.eventId)
25+
.it("should have an eventId", (user, context) => context.eventId)
3126

32-
.it('should have a timestamp', (user, context) => context.timestamp)
27+
.it("should have a timestamp", (user, context) => context.timestamp)
3328

34-
.it('should not have auth', (user, context) =>
35-
expectEq((context as any).auth, undefined)
36-
)
29+
.it("should not have auth", (user, context) => expectEq((context as any).auth, undefined))
3730

38-
.it('should not have action', (user, context) =>
39-
expectEq((context as any).action, undefined)
40-
)
31+
.it("should not have action", (user, context) => expectEq((context as any).action, undefined))
4132

42-
.it('should have properly defined meta', (user, context) => user.metadata)
33+
.it("should have properly defined meta", (user) => user.metadata)
4334

4435
.run(testId, u, c);
4536
});
@@ -51,33 +42,24 @@ export const deleteUserTests: any = functions
5142
const testId: string = u.displayName;
5243
functions.logger.info(`testId is ${testId}`);
5344

54-
return new TestSuite<UserMetadata>('auth user onDelete')
55-
.it('should have a project as resource', (user, context) =>
56-
expectEq(
57-
context.resource.name,
58-
`projects/${process.env.GCLOUD_PROJECT}`
59-
)
45+
return new TestSuite<UserMetadata>("auth user onDelete")
46+
.it("should have a project as resource", (user, context) =>
47+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
6048
)
6149

62-
.it('should not have a path', (user, context) =>
63-
expectEq((context as any).path, undefined)
64-
)
50+
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
6551

66-
.it('should have the correct eventType', (user, context) =>
67-
expectEq(context.eventType, 'google.firebase.auth.user.delete')
52+
.it("should have the correct eventType", (user, context) =>
53+
expectEq(context.eventType, "google.firebase.auth.user.delete")
6854
)
6955

70-
.it('should have an eventId', (user, context) => context.eventId)
56+
.it("should have an eventId", (user, context) => context.eventId)
7157

72-
.it('should have a timestamp', (user, context) => context.timestamp)
58+
.it("should have a timestamp", (user, context) => context.timestamp)
7359

74-
.it('should not have auth', (user, context) =>
75-
expectEq((context as any).auth, undefined)
76-
)
60+
.it("should not have auth", (user, context) => expectEq((context as any).auth, undefined))
7761

78-
.it('should not have action', (user, context) =>
79-
expectEq((context as any).action, undefined)
80-
)
62+
.it("should not have action", (user, context) => expectEq((context as any).action, undefined))
8163

8264
.run(testId, u, c);
8365
});
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectEq, expectMatches, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectEq, expectMatches, TestSuite } from "../testing";
55
import DataSnapshot = admin.database.DataSnapshot;
66

7-
const testIdFieldName = 'testId';
7+
const testIdFieldName = "testId";
88

99
export const databaseTests: any = functions
1010
.region(REGION)
11-
.database.ref('dbTests/{testId}/start')
11+
.database.ref("dbTests/{testId}/start")
1212
.onWrite((ch, ctx) => {
1313
if (ch.after.val() === null) {
1414
functions.logger.info(
15-
'Event for ' +
16-
ctx.params[testIdFieldName] +
17-
' is null; presuming data cleanup, so skipping.'
15+
`Event for ${ctx.params[testIdFieldName]} is null; presuming data cleanup, so skipping.`
1816
);
1917
return;
2018
}
2119

22-
return new TestSuite<functions.Change<DataSnapshot>>('database ref onWrite')
20+
return new TestSuite<functions.Change<DataSnapshot>>("database ref onWrite")
2321

24-
.it(
25-
'should not have event.app',
26-
(change, context) => !(context as any).app
27-
)
22+
.it("should not have event.app", (change, context) => !(context as any).app)
2823

29-
.it('should give refs access to admin data', (change) =>
24+
.it("should give refs access to admin data", (change) =>
3025
change.after.ref.parent
31-
.child('adminOnly')
26+
.child("adminOnly")
3227
.update({ allowed: 1 })
3328
.then(() => true)
3429
)
3530

36-
.it('should have a correct ref url', (change) => {
31+
.it("should have a correct ref url", (change) => {
3732
const url = change.after.ref.toString();
3833
return Promise.resolve()
3934
.then(() => {
@@ -49,7 +44,7 @@ export const databaseTests: any = functions
4944
});
5045
})
5146

52-
.it('should have refs resources', (change, context) =>
47+
.it("should have refs resources", (change, context) =>
5348
expectMatches(
5449
context.resource.name,
5550
new RegExp(
@@ -58,25 +53,23 @@ export const databaseTests: any = functions
5853
)
5954
)
6055

61-
.it('should not include path', (change, context) =>
56+
.it("should not include path", (change, context) =>
6257
expectEq((context as any).path, undefined)
6358
)
6459

65-
.it('should have the right eventType', (change, context) =>
66-
expectEq(context.eventType, 'google.firebase.database.ref.write')
60+
.it("should have the right eventType", (change, context) =>
61+
expectEq(context.eventType, "google.firebase.database.ref.write")
6762
)
6863

69-
.it('should have eventId', (change, context) => context.eventId)
64+
.it("should have eventId", (change, context) => context.eventId)
7065

71-
.it('should have timestamp', (change, context) => context.timestamp)
66+
.it("should have timestamp", (change, context) => context.timestamp)
7267

73-
.it('should not have action', (change, context) =>
68+
.it("should not have action", (change, context) =>
7469
expectEq((context as any).action, undefined)
7570
)
7671

77-
.it('should have admin authType', (change, context) =>
78-
expectEq(context.authType, 'ADMIN')
79-
)
72+
.it("should have admin authType", (change, context) => expectEq(context.authType, "ADMIN"))
8073

8174
.run(ctx.params[testIdFieldName], ch, ctx);
8275
});

integration_test/functions/src/v1/firestore-tests.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectDeepEq, expectEq, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectDeepEq, expectEq, TestSuite } from "../testing";
55
import DocumentSnapshot = admin.firestore.DocumentSnapshot;
66

7-
const testIdFieldName = 'documentId';
7+
const testIdFieldName = "documentId";
88

99
export const firestoreTests: any = functions
1010
.runWith({
1111
timeoutSeconds: 540,
1212
})
1313
.region(REGION)
14-
.firestore.document('tests/{documentId}')
14+
.firestore.document("tests/{documentId}")
1515
.onCreate((s, c) => {
16-
return new TestSuite<DocumentSnapshot>('firestore document onWrite')
16+
return new TestSuite<DocumentSnapshot>("firestore document onWrite")
1717

18-
.it('should not have event.app', (snap, context) => !(context as any).app)
18+
.it("should not have event.app", (snap, context) => !(context as any).app)
1919

20-
.it('should give refs write access', (snap) =>
20+
.it("should give refs write access", (snap) =>
2121
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true)
2222
)
2323

24-
.it('should have well-formatted resource', (snap, context) =>
24+
.it("should have well-formatted resource", (snap, context) =>
2525
expectEq(
2626
context.resource.name,
2727
`projects/${process.env.GCLOUD_PROJECT}/databases/(default)/documents/tests/${context.params.documentId}`
2828
)
2929
)
3030

31-
.it('should have the right eventType', (snap, context) =>
32-
expectEq(context.eventType, 'google.firestore.document.create')
31+
.it("should have the right eventType", (snap, context) =>
32+
expectEq(context.eventType, "google.firestore.document.create")
3333
)
3434

35-
.it('should have eventId', (snap, context) => context.eventId)
35+
.it("should have eventId", (snap, context) => context.eventId)
3636

37-
.it('should have timestamp', (snap, context) => context.timestamp)
37+
.it("should have timestamp", (snap, context) => context.timestamp)
3838

39-
.it('should have the correct data', (snap, context) =>
39+
.it("should have the correct data", (snap, context) =>
4040
expectDeepEq(snap.data(), { test: context.params.documentId })
4141
)
4242

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import * as functions from 'firebase-functions';
2-
import { REGION } from '../region';
3-
import { expectEq, TestSuite } from '../testing';
1+
import * as functions from "firebase-functions";
2+
import { REGION } from "../region";
3+
import { expectEq, TestSuite } from "../testing";
44

55
export const callableTests: any = functions
6-
.runWith({ invoker: 'private' })
6+
.runWith({ invoker: "private" })
77
.region(REGION)
88
.https.onCall((d) => {
9-
return new TestSuite('https onCall')
10-
.it('should have the correct data', (data: any) =>
11-
expectEq(data?.foo, 'bar')
12-
)
9+
return new TestSuite("https onCall")
10+
.it("should have the correct data", (data: any) => expectEq(data?.foo, "bar"))
1311
.run(d.testId, d);
1412
});
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export * from './pubsub-tests';
2-
export * from './database-tests';
3-
export * from './auth-tests';
4-
export * from './firestore-tests';
5-
export * from './https-tests';
6-
export * from './remoteConfig-tests';
7-
export * from './storage-tests';
8-
export * from './testLab-tests';
1+
export * from "./pubsub-tests";
2+
export * from "./database-tests";
3+
export * from "./auth-tests";
4+
export * from "./firestore-tests";
5+
export * from "./https-tests";
6+
export * from "./remoteConfig-tests";
7+
export * from "./storage-tests";
8+
export * from "./testLab-tests";
Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { evaluate, expectEq, success, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { evaluate, expectEq, success, TestSuite } from "../testing";
55
import PubsubMessage = functions.pubsub.Message;
66

77
// TODO(inlined) use multiple queues to run inline.
88
// Expected message data: {"hello": "world"}
99
export const pubsubTests: any = functions
1010
.region(REGION)
11-
.pubsub.topic('pubsubTests')
11+
.pubsub.topic("pubsubTests")
1212
.onPublish((m, c) => {
1313
let testId: string;
1414
try {
@@ -17,63 +17,51 @@ export const pubsubTests: any = functions
1717
/* Ignored. Covered in another test case that `event.data.json` works. */
1818
}
1919

20-
return new TestSuite<PubsubMessage>('pubsub onPublish')
21-
.it('should have a topic as resource', (message, context) =>
22-
expectEq(
23-
context.resource.name,
24-
`projects/${process.env.GCLOUD_PROJECT}/topics/pubsubTests`
25-
)
20+
return new TestSuite<PubsubMessage>("pubsub onPublish")
21+
.it("should have a topic as resource", (message, context) =>
22+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}/topics/pubsubTests`)
2623
)
2724

28-
.it('should not have a path', (message, context) =>
25+
.it("should not have a path", (message, context) =>
2926
expectEq((context as any).path, undefined)
3027
)
3128

32-
.it('should have the correct eventType', (message, context) =>
33-
expectEq(context.eventType, 'google.pubsub.topic.publish')
29+
.it("should have the correct eventType", (message, context) =>
30+
expectEq(context.eventType, "google.pubsub.topic.publish")
3431
)
3532

36-
.it('should have an eventId', (message, context) => context.eventId)
33+
.it("should have an eventId", (message, context) => context.eventId)
3734

38-
.it('should have a timestamp', (message, context) => context.timestamp)
35+
.it("should have a timestamp", (message, context) => context.timestamp)
3936

40-
.it('should not have auth', (message, context) =>
41-
expectEq((context as any).auth, undefined)
42-
)
37+
.it("should not have auth", (message, context) => expectEq((context as any).auth, undefined))
4338

44-
.it('should not have action', (message, context) =>
39+
.it("should not have action", (message, context) =>
4540
expectEq((context as any).action, undefined)
4641
)
4742

48-
.it('should have pubsub data', (message) => {
49-
const decoded = new Buffer(message.data, 'base64').toString();
43+
.it("should have pubsub data", (message) => {
44+
const decoded = new Buffer(message.data, "base64").toString();
5045
const parsed = JSON.parse(decoded);
51-
return evaluate(
52-
parsed.hasOwnProperty('testId'),
53-
'Raw data was: ' + message.data
54-
);
46+
return evaluate(parsed.hasOwnProperty("testId"), `Raw data was + ${message.data}`);
5547
})
5648

57-
.it('should decode JSON payloads with the json helper', (message) =>
58-
evaluate(message.json.hasOwnProperty('testId'), message.json)
49+
.it("should decode JSON payloads with the json helper", (message) =>
50+
evaluate(message.json.hasOwnProperty("testId"), message.json)
5951
)
6052

6153
.run(testId, m, c);
6254
});
6355

6456
export const schedule: any = functions
6557
.region(REGION)
66-
.pubsub.schedule('every 10 hours') // This is a dummy schedule, since we need to put a valid one in.
58+
.pubsub.schedule("every 10 hours") // This is a dummy schedule, since we need to put a valid one in.
6759
// For the test, the job is triggered by the jobs:run api
68-
.onRun(async (context) => {
60+
.onRun(async () => {
6961
const db = admin.database();
70-
const snap = await db
71-
.ref('testRuns')
72-
.orderByChild('timestamp')
73-
.limitToLast(1)
74-
.once('value');
62+
const snap = await db.ref("testRuns").orderByChild("timestamp").limitToLast(1).once("value");
7563
const testId = Object.keys(snap.val())[0];
76-
return new TestSuite('pubsub scheduleOnRun')
77-
.it('should trigger when the scheduler fires', () => success())
64+
return new TestSuite("pubsub scheduleOnRun")
65+
.it("should trigger when the scheduler fires", () => success())
7866
.run(testId, null);
7967
});

0 commit comments

Comments
 (0)