Skip to content

Commit 1f1df53

Browse files
committed
added MilestoneEntity
1 parent 9f8584d commit 1f1df53

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`should match snapshot when providing all fields: errors 1`] = `Array []`;
4+
5+
exports[`should match snapshot when providing all fields: output 1`] = `
6+
MilestoneEntity {
7+
"closedAt": "2022-08-30T09:55:46Z",
8+
"closedIssuesCount": 2,
9+
"createdAt": "2022-08-18T09:55:46Z",
10+
"description": "Adding an Arabic version of dzcode.io",
11+
"dueAt": "2022-08-30T09:55:46Z",
12+
"id": "8320713",
13+
"openIssuesCount": 4,
14+
"status": "open",
15+
"title": "Localization (web)",
16+
"url": "https://github.com/dzcode-io/dzcode.io/milestone/9",
17+
}
18+
`;
19+
20+
exports[`should match snapshot when providing required fields only: errors 1`] = `Array []`;
21+
22+
exports[`should match snapshot when providing required fields only: output 1`] = `
23+
MilestoneEntity {
24+
"closedIssuesCount": 2,
25+
"createdAt": "2022-08-18T09:55:46Z",
26+
"description": "Adding an Arabic version of dzcode.io",
27+
"id": "8320713",
28+
"openIssuesCount": 4,
29+
"status": "open",
30+
"title": "Localization (web)",
31+
"url": "https://github.com/dzcode-io/dzcode.io/milestone/9",
32+
}
33+
`;
34+
35+
exports[`should show an error that matches snapshot when passing empty object: errors 1`] = `
36+
Array [
37+
ValidationError {
38+
"children": Array [],
39+
"constraints": Object {
40+
"isString": "id must be a string",
41+
},
42+
"property": "id",
43+
"target": MilestoneEntity {},
44+
"value": undefined,
45+
},
46+
ValidationError {
47+
"children": Array [],
48+
"constraints": Object {
49+
"isString": "title must be a string",
50+
},
51+
"property": "title",
52+
"target": MilestoneEntity {},
53+
"value": undefined,
54+
},
55+
ValidationError {
56+
"children": Array [],
57+
"constraints": Object {
58+
"isString": "description must be a string",
59+
},
60+
"property": "description",
61+
"target": MilestoneEntity {},
62+
"value": undefined,
63+
},
64+
ValidationError {
65+
"children": Array [],
66+
"constraints": Object {
67+
"isUrl": "url must be an URL address",
68+
},
69+
"property": "url",
70+
"target": MilestoneEntity {},
71+
"value": undefined,
72+
},
73+
ValidationError {
74+
"children": Array [],
75+
"constraints": Object {
76+
"isNumber": "openIssuesCount must be a number conforming to the specified constraints",
77+
},
78+
"property": "openIssuesCount",
79+
"target": MilestoneEntity {},
80+
"value": undefined,
81+
},
82+
ValidationError {
83+
"children": Array [],
84+
"constraints": Object {
85+
"isNumber": "closedIssuesCount must be a number conforming to the specified constraints",
86+
},
87+
"property": "closedIssuesCount",
88+
"target": MilestoneEntity {},
89+
"value": undefined,
90+
},
91+
ValidationError {
92+
"children": Array [],
93+
"constraints": Object {
94+
"isString": "status must be a string",
95+
},
96+
"property": "status",
97+
"target": MilestoneEntity {},
98+
"value": undefined,
99+
},
100+
ValidationError {
101+
"children": Array [],
102+
"constraints": Object {
103+
"isDateString": "createdAt must be a valid ISO 8601 date string",
104+
},
105+
"property": "createdAt",
106+
"target": MilestoneEntity {},
107+
"value": undefined,
108+
},
109+
]
110+
`;
111+
112+
exports[`should show an error that matches snapshot when passing empty object: output 1`] = `MilestoneEntity {}`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { runDTOTestCases } from "../_test";
2+
import { MilestoneEntity } from ".";
3+
4+
runDTOTestCases(
5+
MilestoneEntity,
6+
{
7+
id: "8320713",
8+
title: "Localization (web)",
9+
description: "Adding an Arabic version of dzcode.io",
10+
url: "https://github.com/dzcode-io/dzcode.io/milestone/9",
11+
status: "open",
12+
closedIssuesCount: 2,
13+
openIssuesCount: 4,
14+
createdAt: "2022-08-18T09:55:46Z",
15+
},
16+
{
17+
closedAt: "2022-08-30T09:55:46Z",
18+
dueAt: "2022-08-30T09:55:46Z",
19+
},
20+
);
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { IsDateString, IsNumber, IsOptional, IsString, IsUrl } from "class-validator";
2+
3+
import { BaseEntity } from "../_base";
4+
5+
export class MilestoneEntity extends BaseEntity {
6+
@IsString()
7+
id!: string;
8+
9+
@IsString()
10+
title!: string;
11+
12+
@IsString()
13+
description!: string;
14+
15+
@IsUrl()
16+
url!: string;
17+
18+
@IsNumber()
19+
openIssuesCount!: number;
20+
21+
@IsNumber()
22+
closedIssuesCount!: number;
23+
24+
@IsString()
25+
status!: "open" | "closed";
26+
27+
@IsDateString()
28+
createdAt!: string;
29+
30+
@IsDateString()
31+
@IsOptional()
32+
dueAt?: string;
33+
34+
@IsDateString()
35+
@IsOptional()
36+
closedAt?: string;
37+
}

0 commit comments

Comments
 (0)