forked from Azure/autorest.typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequiredOptional.spec.ts
203 lines (174 loc) · 6.9 KB
/
requiredOptional.spec.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { RequiredOptionalClient } from "./generated/requiredOptional/src";
import { assert } from "chai";
import { responseStatusChecker } from "../utils/responseStatusChecker";
describe("Swagger that needs no mapper", () => {
let client: RequiredOptionalClient;
beforeEach(() => {
client = new RequiredOptionalClient("one", "two", {
allowInsecureConnection: true
});
});
describe("Implicit Optional", () => {
it("should handle putOptionalQuery", async () => {
await client.implicit.putOptionalQuery(responseStatusChecker);
});
it("should handle putOptionalHeader", async () => {
await client.implicit.putOptionalHeader(responseStatusChecker);
});
it("should handle putOptionalBody", async () => {
await client.implicit.putOptionalBody(responseStatusChecker);
});
it("should handle getOptionalGlobalQuery", async () => {
await client.implicit.getOptionalGlobalQuery(responseStatusChecker);
});
it("should handle getRequiredPath", async () => {
try {
await client.implicit.getRequiredPath(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle getRequiredGlobalPath", async () => {
try {
client = new RequiredOptionalClient(null as any, null as any, {
allowInsecureConnection: true
});
await client.implicit.getRequiredGlobalPath();
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle getRequiredGlobalQuery", async () => {
client = new RequiredOptionalClient(null as any, null as any, {
allowInsecureConnection: true
});
try {
await client.implicit.getRequiredGlobalQuery();
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
});
describe("Explicit Optional", () => {
it("should handle postOptionalArrayHeader", async () => {
await client.explicit.postOptionalArrayHeader(responseStatusChecker);
});
it("should handle postOptionalArrayParameter", async () => {
await client.explicit.postOptionalArrayParameter(responseStatusChecker);
});
it("should handle postOptionalArrayProperty", async () => {
await client.explicit.postOptionalArrayProperty(responseStatusChecker);
});
it("should handle postOptionalClassParameter", async () => {
await client.explicit.postOptionalClassParameter(responseStatusChecker);
});
it("should handle postOptionalClassProperty", async () => {
await client.explicit.postOptionalClassProperty(responseStatusChecker);
});
it("should handle postOptionalIntegerHeader", async () => {
await client.explicit.postOptionalIntegerHeader(responseStatusChecker);
});
it("should handle postOptionalIntegerParameter", async () => {
await client.explicit.postOptionalIntegerParameter(responseStatusChecker);
});
it("should handle postOptionalIntegerProperty", async () => {
await client.explicit.postOptionalIntegerProperty(responseStatusChecker);
});
it("should handle postOptionalStringHeader", async () => {
await client.explicit.postOptionalStringHeader(responseStatusChecker);
});
it("should handle postOptionalStringParameter", async () => {
await client.explicit.postOptionalStringParameter(responseStatusChecker);
});
it("should handle postOptionalStringProperty", async () => {
await client.explicit.postOptionalStringProperty(responseStatusChecker);
});
it("should handle postRequiredArrayHeader", async () => {
try {
await client.explicit.postRequiredArrayHeader(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredArrayParameter", async () => {
try {
await client.explicit.postRequiredArrayParameter(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredArrayProperty", async () => {
try {
await client.explicit.postRequiredArrayProperty({ value: null } as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
// https://github.com/Azure/autorest.typescript/issues/759
it.skip("should handle postRequiredClassParameter", async () => {
try {
await client.explicit.postRequiredClassParameter(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
// https://github.com/Azure/autorest.typescript/issues/759
it.skip("should handle postRequiredClassProperty", async () => {
try {
await client.explicit.postRequiredClassProperty({ value: null } as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredIntegerHeader", async () => {
try {
await client.explicit.postRequiredIntegerHeader(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredIntegerParameter", async () => {
try {
await client.explicit.postRequiredIntegerParameter(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredStringHeader", async () => {
try {
await client.explicit.postRequiredStringHeader(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredStringParameter", async () => {
try {
await client.explicit.postRequiredStringParameter(null as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
it("should handle postRequiredStringProperty", async () => {
try {
await client.explicit.postRequiredStringProperty({
value: null
} as any);
assert.fail("Expected client to throw");
} catch (error) {
assert.include(error.message, "cannot be null or undefined");
}
});
});
});