forked from Azure/autorest.typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbodyDate.spec.ts
63 lines (53 loc) · 2.16 KB
/
bodyDate.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
import { BodyDateClient } from "./generated/bodyDate/src";
import { expect } from "chai";
import { responseStatusChecker } from "../utils/responseStatusChecker";
describe("BodyDateClient", function() {
let testClient: BodyDateClient;
beforeEach(() => {
testClient = new BodyDateClient({ allowInsecureConnection: true });
});
it("should get min date", async () => {
const { body: date } = await testClient.date.getMinDate();
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 max date", async () => {
const { body: date } = await testClient.date.getMaxDate();
expect(date.getUTCFullYear()).to.equal(9999);
expect(date.getUTCMonth()).to.equal(11);
expect(date.getUTCDate()).to.equal(31);
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 handle overflow date", async () => {
const { body: date } = await testClient.date.getOverflowDate();
expect(isNaN(date.valueOf())).to.equal(true);
});
it("should handle undeflow date", async () => {
const { body: date } = await testClient.date.getUnderflowDate();
expect(isNaN(date.valueOf())).to.equal(true);
});
it("should get a null value", async () => {
const { body: date } = await testClient.date.getNull();
expect(date).to.equal(undefined);
});
it("should get an invalid value", async () => {
const { body: date } = await testClient.date.getInvalidDate();
expect(isNaN(date.valueOf())).to.equal(true);
});
it("should put max date", async () => {
const maxDate = new Date("9999-12-31");
await testClient.date.putMaxDate(maxDate, responseStatusChecker);
});
it("should put min date", async () => {
const minDate = new Date("0001-01-01");
await testClient.date.putMinDate(minDate, responseStatusChecker);
});
});