Skip to content

Commit 957056e

Browse files
Removing usage of "any"
1 parent 7072718 commit 957056e

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

packages/firestore/test/integration/api/validation.test.ts

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,52 @@ import {
3030
// We're using 'as any' to pass invalid values to APIs for testing purposes.
3131
// tslint:disable:no-any
3232

33+
interface ValidationIt {
34+
(persistence: boolean, message: string, testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>) : void,
35+
skip: (persistence: boolean,
36+
message: string,
37+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>) => void,
38+
only: (persistence: boolean,
39+
message: string,
40+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>) => void
41+
}
42+
3343
// Since most of our tests are "synchronous" but require a Firestore instance,
3444
// we have a helper wrapper around it() and withTestDb() to optimize for that.
35-
const validationIt: any = function(
36-
persistence: boolean,
37-
message: string,
38-
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
39-
) {
40-
it(message, () => {
41-
return withTestDb(persistence, async db => {
42-
const maybePromise = testFunction(db);
43-
if (maybePromise) {
44-
return maybePromise;
45-
}
46-
});
47-
});
48-
};
49-
50-
validationIt.skip = function(
51-
persistence: boolean,
52-
message: string,
53-
_: (db: firestore.FirebaseFirestore) => void | Promise<any>
54-
) {
55-
it.skip(message, () => {});
56-
};
57-
58-
validationIt.only = function(
59-
persistence: boolean,
60-
message: string,
61-
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
62-
) {
63-
it.only(message, () => {
64-
return withTestDb(persistence, async db => {
65-
const maybePromise = testFunction(db);
66-
if (maybePromise) {
67-
return maybePromise;
45+
const validationIt: ValidationIt = Object.assign(
46+
(persistence: boolean,
47+
message: string,
48+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>) => {
49+
it(message, () => {
50+
return withTestDb(persistence, async db => {
51+
const maybePromise = testFunction(db);
52+
if (maybePromise) {
53+
return maybePromise;
54+
}
55+
});
56+
});
57+
},
58+
{
59+
skip: function (persistence: boolean,
60+
message: string,
61+
_: (db: firestore.FirebaseFirestore) => void | Promise<any>) {
62+
it.skip(message, () => {
63+
});
64+
},
65+
only: function (persistence: boolean,
66+
message: string,
67+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>) {
68+
it.only(message, () => {
69+
return withTestDb(persistence, async db => {
70+
const maybePromise = testFunction(db);
71+
if (maybePromise) {
72+
return maybePromise;
73+
}
74+
});
75+
});
6876
}
69-
});
70-
});
71-
};
77+
}
78+
);
7279

7380
// NOTE: The JS SDK does extensive validation of argument counts, types, etc.
7481
// since it is an untyped language. These tests are not exhaustive as that would

0 commit comments

Comments
 (0)