Skip to content

Commit 01665ef

Browse files
authored
Use prettier instead of linter (#204)
1 parent 6c1cdca commit 01665ef

38 files changed

+1457
-782
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5"
4+
}

integration_test/functions/src/auth-tests.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,29 @@ export const createUserTests: any = functions.auth.user().onCreate((u, c) => {
88
console.log(`testId is ${testId}`);
99

1010
return new TestSuite<UserMetadata>('auth user onCreate')
11-
.it('should have a project as resource', (user, context) => expectEq(
12-
context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))
11+
.it('should have a project as resource', (user, context) =>
12+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
13+
)
1314

14-
.it('should not have a path', (user, context) => expectEq((context as any).path, undefined))
15+
.it('should not have a path', (user, context) =>
16+
expectEq((context as any).path, undefined)
17+
)
1518

16-
.it('should have the correct eventType', (user, context) => expectEq(
17-
context.eventType, 'google.firebase.auth.user.create'))
19+
.it('should have the correct eventType', (user, context) =>
20+
expectEq(context.eventType, 'google.firebase.auth.user.create')
21+
)
1822

19-
.it('should have an eventId', (user, context)=> context.eventId)
23+
.it('should have an eventId', (user, context) => context.eventId)
2024

2125
.it('should have a timestamp', (user, context) => context.timestamp)
2226

23-
.it('should not have auth', (user, context) => expectEq((context as any).auth, undefined))
27+
.it('should not have auth', (user, context) =>
28+
expectEq((context as any).auth, undefined)
29+
)
2430

25-
.it('should not have action', (user, context) => expectEq((context as any).action, undefined))
31+
.it('should not have action', (user, context) =>
32+
expectEq((context as any).action, undefined)
33+
)
2634

2735
.run(testId, u, c);
2836
});
@@ -32,21 +40,29 @@ export const deleteUserTests: any = functions.auth.user().onDelete((u, c) => {
3240
console.log(`testId is ${testId}`);
3341

3442
return new TestSuite<UserMetadata>('auth user onDelete')
35-
.it('should have a project as resource', (user, context) => expectEq(
36-
context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))
43+
.it('should have a project as resource', (user, context) =>
44+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
45+
)
3746

38-
.it('should not have a path', (user, context) => expectEq((context as any).path, undefined))
47+
.it('should not have a path', (user, context) =>
48+
expectEq((context as any).path, undefined)
49+
)
3950

40-
.it('should have the correct eventType', (user, context) => expectEq(
41-
context.eventType, 'google.firebase.auth.user.delete'))
51+
.it('should have the correct eventType', (user, context) =>
52+
expectEq(context.eventType, 'google.firebase.auth.user.delete')
53+
)
4254

4355
.it('should have an eventId', (user, context) => context.eventId)
4456

4557
.it('should have a timestamp', (user, context) => context.timestamp)
4658

47-
.it('should not have auth', (user, context) => expectEq((context as any).auth, undefined))
59+
.it('should not have auth', (user, context) =>
60+
expectEq((context as any).auth, undefined)
61+
)
4862

49-
.it('should not have action', (user, context) => expectEq((context as any).action, undefined))
63+
.it('should not have action', (user, context) =>
64+
expectEq((context as any).action, undefined)
65+
)
5066

5167
.run(testId, u, c);
5268
});

integration_test/functions/src/database-tests.ts

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,72 @@ import DataSnapshot = admin.database.DataSnapshot;
55

66
const testIdFieldName = 'testId';
77

8-
export const databaseTests: any = functions.database.ref('dbTests/{testId}/start').onWrite((ch, ctx) => {
9-
if (ch.after.val() === null) {
10-
console.log(
11-
'Event for ' + ctx.params[testIdFieldName]
12-
+ ' is null; presuming data cleanup, so skipping.');
13-
return;
14-
}
8+
export const databaseTests: any = functions.database
9+
.ref('dbTests/{testId}/start')
10+
.onWrite((ch, ctx) => {
11+
if (ch.after.val() === null) {
12+
console.log(
13+
'Event for ' +
14+
ctx.params[testIdFieldName] +
15+
' is null; presuming data cleanup, so skipping.'
16+
);
17+
return;
18+
}
1519

16-
return new TestSuite<functions.Change<DataSnapshot>>('database ref onWrite')
20+
return new TestSuite<functions.Change<DataSnapshot>>('database ref onWrite')
1721

18-
.it('should not have event.app', (change, context) => !(context as any).app)
22+
.it(
23+
'should not have event.app',
24+
(change, context) => !(context as any).app
25+
)
1926

20-
.it('should give refs access to admin data', (change) =>
21-
change.after.ref.parent.child('adminOnly').update({ allowed: 1 }).then(() => true))
27+
.it('should give refs access to admin data', change =>
28+
change.after.ref.parent
29+
.child('adminOnly')
30+
.update({ allowed: 1 })
31+
.then(() => true)
32+
)
2233

23-
.it('should have a correct ref url', (change) => {
24-
const url = change.after.ref.toString();
25-
return Promise.resolve().then(() => {
26-
return expectMatches(url, new RegExp(`^https://${process.env.GCLOUD_PROJECT}.firebaseio.com/dbTests`));
27-
}).then(() => {
28-
return expectMatches(url, /\/start$/);
29-
});
30-
})
34+
.it('should have a correct ref url', change => {
35+
const url = change.after.ref.toString();
36+
return Promise.resolve()
37+
.then(() => {
38+
return expectMatches(
39+
url,
40+
new RegExp(
41+
`^https://${process.env.GCLOUD_PROJECT}.firebaseio.com/dbTests`
42+
)
43+
);
44+
})
45+
.then(() => {
46+
return expectMatches(url, /\/start$/);
47+
});
48+
})
3149

32-
.it('should have refs resources', (change, context) => expectEq(
33-
context.resource.name,
34-
`projects/_/instances/${process.env.GCLOUD_PROJECT}/refs/dbTests/${context.params.testId}/start`))
50+
.it('should have refs resources', (change, context) =>
51+
expectEq(
52+
context.resource.name,
53+
`projects/_/instances/${process.env.GCLOUD_PROJECT}/refs/dbTests/${
54+
context.params.testId
55+
}/start`
56+
)
57+
)
3558

36-
.it('should not include path', (change, context) => expectEq((context as any).path, undefined))
59+
.it('should not include path', (change, context) =>
60+
expectEq((context as any).path, undefined)
61+
)
3762

38-
.it('should have the right eventType', (change, context) => expectEq(
39-
context.eventType, 'google.firebase.database.ref.write'))
63+
.it('should have the right eventType', (change, context) =>
64+
expectEq(context.eventType, 'google.firebase.database.ref.write')
65+
)
4066

41-
.it('should have eventId', (change, context) => context.eventId)
67+
.it('should have eventId', (change, context) => context.eventId)
4268

43-
.it('should have timestamp', (change, context) => context.timestamp)
69+
.it('should have timestamp', (change, context) => context.timestamp)
4470

45-
.it('should not have action', (change, context) => expectEq((context as any).action, undefined))
71+
.it('should not have action', (change, context) =>
72+
expectEq((context as any).action, undefined)
73+
)
4674

47-
.run(ctx.params[testIdFieldName], ch, ctx);
48-
});
75+
.run(ctx.params[testIdFieldName], ch, ctx);
76+
});

integration_test/functions/src/firestore-tests.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,37 @@ import DocumentSnapshot = admin.firestore.DocumentSnapshot;
55

66
const testIdFieldName = 'documentId';
77

8-
export const firestoreTests: any = functions.firestore.document('tests/{documentId}').onCreate((s, c) => {
9-
return new TestSuite<DocumentSnapshot>('firestore document onWrite')
8+
export const firestoreTests: any = functions.firestore
9+
.document('tests/{documentId}')
10+
.onCreate((s, c) => {
11+
return new TestSuite<DocumentSnapshot>('firestore document onWrite')
1012

11-
.it('should not have event.app', (snap, context) => !(context as any).app)
13+
.it('should not have event.app', (snap, context) => !(context as any).app)
1214

13-
.it('should give refs write access', (snap) =>
14-
snap.ref.set({ allowed: 1 }, {merge: true}).then(() => true))
15+
.it('should give refs write access', snap =>
16+
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true)
17+
)
1518

16-
.it('should have well-formatted resource', (snap, context) => expectEq(
17-
context.resource.name,
18-
`projects/${process.env.GCLOUD_PROJECT}/databases/(default)/documents/tests/${context.params.documentId}`)
19-
)
19+
.it('should have well-formatted resource', (snap, context) =>
20+
expectEq(
21+
context.resource.name,
22+
`projects/${
23+
process.env.GCLOUD_PROJECT
24+
}/databases/(default)/documents/tests/${context.params.documentId}`
25+
)
26+
)
2027

21-
.it('should have the right eventType', (snap, context) => expectEq(
22-
context.eventType, 'google.firestore.document.create'))
28+
.it('should have the right eventType', (snap, context) =>
29+
expectEq(context.eventType, 'google.firestore.document.create')
30+
)
2331

24-
.it('should have eventId', (snap, context) => context.eventId)
32+
.it('should have eventId', (snap, context) => context.eventId)
2533

26-
.it('should have timestamp', (snap, context) => context.timestamp)
34+
.it('should have timestamp', (snap, context) => context.timestamp)
2735

28-
.it('should have the correct data', (snap, context) => expectDeepEq(snap.data(), {test: context.params.documentId}))
36+
.it('should have the correct data', (snap, context) =>
37+
expectDeepEq(snap.data(), { test: context.params.documentId })
38+
)
2939

30-
.run(c.params[testIdFieldName], s, c);
31-
});
40+
.run(c.params[testIdFieldName], s, c);
41+
});

integration_test/functions/src/https-tests.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { TestSuite, expectEq } from './testing';
44

55
export const callableTests: any = functions.https.onCall(d => {
66
return new TestSuite('https onCall')
7-
.it('should have the correct data', data => expectEq(_.get(data, 'foo'), 'bar'))
7+
.it('should have the correct data', data =>
8+
expectEq(_.get(data, 'foo'), 'bar')
9+
)
810
.run(d.testId, d);
911
});

0 commit comments

Comments
 (0)