forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.d.ts
116 lines (101 loc) · 3.95 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { OneOrMore } from './src/mongo_types';
import type { TestConfiguration } from './test/tools/runner/config';
declare global {
interface MongoDBMetadataUI {
requires?: {
topology?: TopologyTypeRequirement;
mongodb?: string;
os?: NodeJS.Platform | `!${NodeJS.Platform}`;
apiVersion?: '1' | boolean;
clientSideEncryption?: boolean;
serverless?: 'forbid' | 'allow' | 'require';
auth?: 'enabled' | 'disabled';
};
sessions?: {
skipLeakTests?: boolean;
};
}
type WithExclusion<T extends string> = `!${T}`;
/** Defined in test/tools/runner/filters/mongodb_topology_filter.js (topologyTypeToString) */
type TopologyTypes = 'single' | 'replicaset' | 'sharded' | 'load-balanced';
type TopologyTypeRequirement = OneOrMore<TopologyTypes> | OneOrMore<WithExclusion<TopologyTypes>>;
interface MetadataAndTest<Fn> {
metadata: MongoDBMetadataUI;
test: Fn;
}
namespace Chai {
interface Assertion {
/** @deprecated Used only by the legacy spec runner, the unified runner implements the unified spec expectations */
matchMongoSpec: (anything: any) => Chai.Assertion;
}
}
namespace Mocha {
interface SuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: (this: Suite) => void): Mocha.Suite;
}
interface PendingSuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: (this: Suite) => void): Mocha.Suite;
}
interface ExclusiveSuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface ExclusiveTestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface TestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface PendingTestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface Context {
configuration: TestConfiguration;
}
interface Test {
metadata: MongoDBMetadataUI;
spec: Record<string, any>;
}
interface Runnable {
/**
* An optional string the test author can attach to print out why a test is skipped
*
* @example
* ```ts
* it.skip('my test', () => {
* //...
* }).skipReason = 'TODO(NODE-XXXX): Feature implementation impending!';
* ```
*
* The reporter (`test/tools/reporter/mongodb_reporter.js`) will print out the skipReason
* indented directly below the test name.
* ```txt
* - my test
* - TODO(NODE-XXXX): Feature implementation impending!
* ```
*
* You can also skip a set of tests via beforeEach:
* ```ts
* beforeEach(() => {
* if ('some condition') {
* this.currentTest.skipReason = 'requires <run condition> to run';
* this.skip();
* }
* });
* ```
*/
skipReason?: string;
}
}
}