forked from Azure/autorest.typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbodyDateTime.spec.ts
208 lines (176 loc) · 7.09 KB
/
bodyDateTime.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
204
205
206
207
208
import { BodyDateTimeClient } from "./generated/bodyDateTime/src";
import { expect } from "chai";
import { responseStatusChecker } from "../utils/responseStatusChecker";
describe("BodyDateTime Client", function() {
let testClient: BodyDateTimeClient;
beforeEach(() => {
testClient = new BodyDateTimeClient({ allowInsecureConnection: true });
});
it("should get null datetime", async () => {
const { body: date } = await testClient.datetime.getNull();
expect(date).to.equal(undefined);
});
it("should get invalid datetime", async () => {
const { body: date } = await testClient.datetime.getInvalid();
expect(isNaN(date.valueOf())).to.equal(true);
});
it("should get uppercase UTC max date time", async () => {
const {
body: date
} = await testClient.datetime.getUtcUppercaseMaxDateTime();
expect(date.getUTCFullYear()).to.equal(9999);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
expect(date.getUTCHours()).to.equal(23);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get lowercase UTC min date time", async () => {
const {
body: date
} = await testClient.datetime.getUtcLowercaseMaxDateTime();
expect(date.getUTCFullYear()).to.equal(9999);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
expect(date.getUTCHours()).to.equal(23);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get UTC min datetime", async () => {
const { body: date } = await testClient.datetime.getUtcMinDateTime();
expect(date.getUTCFullYear()).to.equal(1);
expect(date.getUTCMonth()).to.equal(0);
expect(date.getUTCDate()).to.equal(1);
expect(date.getUTCHours()).to.equal(0);
expect(date.getUTCMinutes()).to.equal(0);
expect(date.getUTCSeconds()).to.equal(0);
expect(date.getUTCMilliseconds()).to.equal(0);
});
it("should get local negative offset Min DateTime value", async () => {
const {
body: date
} = await testClient.datetime.getLocalNegativeOffsetMinDateTime();
expect(date.toISOString()).to.equal("0001-01-01T14:00:00.000Z");
});
it("should get local no offset Min DateTime value", async () => {
const {
body: date
} = await testClient.datetime.getLocalNoOffsetMinDateTime();
expect(date.toISOString()).to.equal(
new Date("0001-01-01T00:00:00").toISOString()
);
});
it("should get local positive offset Min DateTime value", async () => {
const {
body: date
} = await testClient.datetime.getLocalPositiveOffsetMinDateTime();
expect(date.getUTCFullYear()).to.equal(0);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
expect(date.getUTCHours()).to.equal(10);
expect(date.getUTCMinutes()).to.equal(0);
expect(date.getUTCSeconds()).to.equal(0);
expect(date.getUTCMilliseconds()).to.equal(0);
});
it("should get local negative offset lowercase Max DateTime", async () => {
const {
body: date
} = await testClient.datetime.getLocalNegativeOffsetLowercaseMaxDateTime();
expect(date.getUTCFullYear()).to.equal(10000);
expect(date.getUTCMonth()).to.equal(0);
expect(date.getUTCDate()).to.equal(1);
expect(date.getUTCHours()).to.equal(13);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get local negative offset uppercase Max DateTime", async () => {
const {
body: date
} = await testClient.datetime.getLocalNegativeOffsetUppercaseMaxDateTime();
expect(date.getUTCFullYear()).to.equal(10000);
expect(date.getUTCMonth()).to.equal(0);
expect(date.getUTCDate()).to.equal(1);
expect(date.getUTCHours()).to.equal(13);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get local positive offset lowercase Max DateTime", async () => {
const {
body: date
} = await testClient.datetime.getLocalPositiveOffsetLowercaseMaxDateTime();
expect(date.getUTCFullYear()).to.equal(9999);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
expect(date.getUTCHours()).to.equal(9);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get local positive offset uppercase Max DateTime", async () => {
const {
body: date
} = await testClient.datetime.getLocalPositiveOffsetUppercaseMaxDateTime();
expect(date).to.deep.equal(new Date("9999-12-31T23:59:59.9999999+14:00"));
expect(date.getUTCFullYear()).to.equal(9999);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
expect(date.getUTCHours()).to.equal(9);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get overflow", async () => {
const { body: date } = await testClient.datetime.getOverflow();
expect(date.getUTCFullYear()).to.equal(10000);
expect(date.getUTCMonth()).to.equal(0);
expect(date.getUTCDate()).to.equal(1);
expect(date.getUTCHours()).to.equal(13);
expect(date.getUTCMinutes()).to.equal(59);
expect(date.getUTCSeconds()).to.equal(59);
expect(date.getUTCMilliseconds()).to.equal(999);
});
it("should get underflow", async () => {
const { body: date } = await testClient.datetime.getUnderflow();
expect(isNaN(date.valueOf())).to.equal(true);
});
it("should put UTC min date time", async () => {
await testClient.datetime.putUtcMinDateTime(
new Date("0001-01-01T00:00:00Z"),
responseStatusChecker
);
});
it("should put UTC max date time", async () => {
await testClient.datetime.putUtcMaxDateTime(
new Date("9999-12-31T23:59:59.9999999Z"),
responseStatusChecker
);
});
it("should put local negative and positive offset min DateTime", async function() {
await testClient.datetime.putLocalNegativeOffsetMinDateTime(
new Date("0001-01-01T00:00:00-14:00"),
responseStatusChecker
);
});
it("should put local negative and positive offset min DateTime", async function() {
await testClient.datetime.putLocalPositiveOffsetMinDateTime(
new Date("0001-01-01T00:00:00+14:00"),
responseStatusChecker
);
});
it("should put local negative offset max DateTime", async () => {
await testClient.datetime.putLocalNegativeOffsetMaxDateTime(
new Date("9999-12-31T23:59:59.9999999-14:00"),
responseStatusChecker
);
});
it("should put local positive offset max Date", async function() {
await testClient.datetime.putLocalPositiveOffsetMaxDateTime(
new Date("9999-12-31t23:59:59.9999999+14:00"),
responseStatusChecker
);
});
});