Skip to content

Commit 790c158

Browse files
Adding .skip and .only for validation tests
Adding .skip and .only for validation tests
2 parents 92f3809 + 5959b54 commit 790c158

File tree

2 files changed

+57
-16
lines changed

2 files changed

+57
-16
lines changed

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

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,65 @@ 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+
(
35+
persistence: boolean,
36+
message: string,
37+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
38+
): void;
39+
skip: (
40+
persistence: boolean,
41+
message: string,
42+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
43+
) => void;
44+
only: (
45+
persistence: boolean,
46+
message: string,
47+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
48+
) => void;
49+
}
50+
3351
// Since most of our tests are "synchronous" but require a Firestore instance,
3452
// we have a helper wrapper around it() and withTestDb() to optimize for that.
35-
function validationIt(
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-
}
53+
const validationIt: ValidationIt = Object.assign(
54+
(
55+
persistence: boolean,
56+
message: string,
57+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
58+
) => {
59+
it(message, () => {
60+
return withTestDb(persistence, async db => {
61+
const maybePromise = testFunction(db);
62+
if (maybePromise) {
63+
return maybePromise;
64+
}
65+
});
4666
});
47-
});
48-
}
67+
},
68+
{
69+
skip: function(
70+
persistence: boolean,
71+
message: string,
72+
_: (db: firestore.FirebaseFirestore) => void | Promise<any>
73+
) {
74+
it.skip(message, () => {});
75+
},
76+
only: function(
77+
persistence: boolean,
78+
message: string,
79+
testFunction: (db: firestore.FirebaseFirestore) => void | Promise<any>
80+
) {
81+
it.only(message, () => {
82+
return withTestDb(persistence, async db => {
83+
const maybePromise = testFunction(db);
84+
if (maybePromise) {
85+
return maybePromise;
86+
}
87+
});
88+
});
89+
}
90+
}
91+
);
4992

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

packages/polyfill/src/polyfills/promise.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,5 @@ const __global = (() => {
3030
// Polyfill Promise
3131
if (typeof Promise === 'undefined') {
3232
// HACK: TS throws an error if I attempt to use 'dot-notation'
33-
__global[
34-
'Promise'
35-
] = require('promise-polyfill') as PromiseConstructor;
33+
__global['Promise'] = require('promise-polyfill') as PromiseConstructor;
3634
}

0 commit comments

Comments
 (0)