-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-sqlscenarios.d.ts
110 lines (100 loc) · 4.08 KB
/
api-sqlscenarios.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
/**
* Represents a context map, which is a collection of key-value pairs where the key is a string and the value is a string.
* The context block is used to provide values that can be replaced in sql statements before execution.
*/
interface ContextMap {
[property: string]: string;
}
/**
* Create a Jest test that executes SQL statements before and after executing.
*
* @param {string} testName - The name of the test.
* @param {string|string[]} sqlSetup - The SQL statements or files to be executed before running the scenario.
* @param {string|string[]} sqlTeardown - The SQL statements or files to be executed after running the scenario.
* @param {() => Promise<void>} testFunc - The Jest test.
* @returns {void}
*/
export interface SqlScenarioTest {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
(
testName: string,
sqlSetup: string | string[],
sqlTeardown: string | string[],
testFunc: () => Promise<void>
): void;
}
/**
* Create a Jest test that executes SQL statements before and after executing.
*
* @param {string} testName - The name of the test.
* @param {ContextMap} initialContext - Initial set of key/value pairs to use for replacing "{key}" elements in sql statements.
* @param {string|string[]} sqlSetup - The SQL statements or files to be executed before running the scenario.
* @param {string|string[]} sqlTeardown - The SQL statements or files to be executed after running the scenario.
* @param {() => Promise<void>} testFunc - The Jest test.
* @returns {void}
*/
export interface SqlScenarioTest {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
(
testName: string,
initialContext: ContextMap,
sqlSetup: string | string[],
sqlTeardown: string | string[],
testFunc: () => Promise<void>
): void;
}
export interface SqlScenarioTest {
skip: SqlScenarioTest;
failing: SqlScenarioTest;
only: SqlScenarioTest;
}
type DescribeBlockWithContextMap = (contextMap?: ContextMap) => void;
/**
* Create a Jest describe block that executes SQL statements before and after executing all the enclosed tests.
*
* @param {string} describeBlockName - The name of the describe block.
* @param {ContextMap} initialContext - Initial set of key/value pairs to use for replacing "{key}" elements in sql statements.
* @param {string|string[]} sqlSetup - The SQL statements or files to be executed before running the scenario.
* @param {string|string[]} sqlTeardown - The SQL statements or files to be executed after running the scenario.
* @param {DescribeBlockWithContextMap} describeBlock - The describe block containing the scenario tests.
* @returns {void}
*/
export interface SqlScenarioDescribe {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
(
describeBlockName: string,
initialContext: ContextMap,
sqlSetup: string | string[],
sqlTeardown: string | string[],
describeBlock: DescribeBlockWithContextMap
): void;
}
/**
* Create a Jest describe block that executes SQL statements before and after executing all the enclosed tests.
* No custom entries for {key} parameter replacement will be added.
*
* @param {string} describeBlockName - The name of the describe block.
* @param {string|string[]} sqlSetup - The SQL statements or files to be executed before running the scenario.
* @param {string|string[]} sqlTeardown - The SQL statements or files to be executed after running the scenario.
* @param {DescribeBlockWithContextMap} describeBlock - The describe block containing the scenario tests.
* @returns {void}
*/
export interface SqlScenarioDescribe {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
(
describeBlockName: string,
sqlSetup: string | string[],
sqlTeardown: string | string[],
describeBlock: DescribeBlockWithContextMap
): void;
}
export interface SqlScenarioDescribe {
skip: SqlScenarioDescribe;
only: SqlScenarioDescribe;
}
declare global {
let sqlScenario: SqlScenarioTest;
let sqlFileScenario: SqlScenarioTest;
let describeSqlScenario: SqlScenarioDescribe;
let describeSqlFileScenario: SqlScenarioDescribe;
}