@mikemajesty/zod-mock-schema 1.0.18 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -34
- package/dist/__tests__/advanced-schemas.spec.js +46 -44
- package/dist/__tests__/advanced-schemas.spec.js.map +1 -1
- package/dist/__tests__/brazilian-formats.spec.js +69 -67
- package/dist/__tests__/brazilian-formats.spec.js.map +1 -1
- package/dist/__tests__/complex-intersections.spec.js +28 -26
- package/dist/__tests__/complex-intersections.spec.js.map +1 -1
- package/dist/__tests__/edge-cases.spec.js +66 -64
- package/dist/__tests__/edge-cases.spec.js.map +1 -1
- package/dist/__tests__/faker-injection.spec.js +40 -38
- package/dist/__tests__/faker-injection.spec.js.map +1 -1
- package/dist/__tests__/overrides-all-types.spec.js +85 -83
- package/dist/__tests__/overrides-all-types.spec.js.map +1 -1
- package/dist/__tests__/overrides.spec.js +95 -93
- package/dist/__tests__/overrides.spec.js.map +1 -1
- package/dist/__tests__/unsupported-types.spec.js +5 -3
- package/dist/__tests__/unsupported-types.spec.js.map +1 -1
- package/dist/__tests__/zod-types.spec.js +314 -308
- package/dist/__tests__/zod-types.spec.js.map +1 -1
- package/dist/cjs/__tests__/advanced-schemas.spec.js +151 -0
- package/dist/cjs/__tests__/advanced-schemas.spec.js.map +1 -0
- package/dist/cjs/__tests__/brazilian-formats.spec.js +207 -0
- package/dist/cjs/__tests__/brazilian-formats.spec.js.map +1 -0
- package/dist/cjs/__tests__/complex-intersections.spec.js +178 -0
- package/dist/cjs/__tests__/complex-intersections.spec.js.map +1 -0
- package/dist/cjs/__tests__/edge-cases.spec.js +208 -0
- package/dist/cjs/__tests__/edge-cases.spec.js.map +1 -0
- package/dist/cjs/__tests__/faker-injection.spec.js +112 -0
- package/dist/cjs/__tests__/faker-injection.spec.js.map +1 -0
- package/dist/cjs/__tests__/overrides-all-types.spec.js +285 -0
- package/dist/cjs/__tests__/overrides-all-types.spec.js.map +1 -0
- package/dist/cjs/__tests__/overrides.spec.js +347 -0
- package/dist/cjs/__tests__/overrides.spec.js.map +1 -0
- package/dist/cjs/__tests__/unsupported-types.spec.js +29 -0
- package/dist/cjs/__tests__/unsupported-types.spec.js.map +1 -0
- package/dist/cjs/__tests__/zod-types.spec.js +532 -0
- package/dist/cjs/__tests__/zod-types.spec.js.map +1 -0
- package/dist/cjs/constants.js +87 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/zod-mock-schema.js +373 -0
- package/dist/cjs/zod-mock-schema.js.map +1 -0
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/types.js +2 -1
- package/dist/zod-mock-schema.js +80 -73
- package/dist/zod-mock-schema.js.map +1 -1
- package/package.json +5 -6
|
@@ -1,345 +1,351 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PersonEntitySchema = void 0;
|
|
7
|
+
const zod_mock_schema_js_1 = require("../zod-mock-schema.js");
|
|
8
|
+
const zod_1 = __importDefault(require("zod"));
|
|
9
|
+
const Identifiable = zod_1.default.object({
|
|
10
|
+
id: zod_1.default.uuid(),
|
|
11
|
+
createdAt: zod_1.default.date(),
|
|
12
|
+
updatedAt: zod_1.default.date().optional(),
|
|
13
|
+
deletedAt: zod_1.default.date().optional().nullable(),
|
|
14
|
+
version: zod_1.default.number().int().positive().default(1),
|
|
9
15
|
});
|
|
10
|
-
const Auditable =
|
|
11
|
-
createdBy:
|
|
12
|
-
updatedBy:
|
|
13
|
-
deletedBy:
|
|
14
|
-
auditLog:
|
|
15
|
-
timestamp:
|
|
16
|
-
action:
|
|
17
|
-
userId:
|
|
18
|
-
changes:
|
|
16
|
+
const Auditable = zod_1.default.object({
|
|
17
|
+
createdBy: zod_1.default.uuid(),
|
|
18
|
+
updatedBy: zod_1.default.uuid().optional(),
|
|
19
|
+
deletedBy: zod_1.default.uuid().optional().nullable(),
|
|
20
|
+
auditLog: zod_1.default.array(zod_1.default.object({
|
|
21
|
+
timestamp: zod_1.default.date(),
|
|
22
|
+
action: zod_1.default.enum(['CREATE', 'UPDATE', 'DELETE', 'RESTORE']),
|
|
23
|
+
userId: zod_1.default.uuid(),
|
|
24
|
+
changes: zod_1.default.record(zod_1.default.string(), zod_1.default.any()).optional(),
|
|
19
25
|
})).max(100).optional(),
|
|
20
26
|
});
|
|
21
|
-
const ContactInfo =
|
|
22
|
-
email:
|
|
23
|
-
phone:
|
|
24
|
-
alternativePhone:
|
|
25
|
-
emergencyContact:
|
|
26
|
-
name:
|
|
27
|
-
relationship:
|
|
28
|
-
phone:
|
|
29
|
-
priority:
|
|
27
|
+
const ContactInfo = zod_1.default.object({
|
|
28
|
+
email: zod_1.default.email(),
|
|
29
|
+
phone: zod_1.default.string().regex(/^\d{10,11}$/),
|
|
30
|
+
alternativePhone: zod_1.default.string().regex(/^\d{10,11}$/).optional(),
|
|
31
|
+
emergencyContact: zod_1.default.object({
|
|
32
|
+
name: zod_1.default.string(),
|
|
33
|
+
relationship: zod_1.default.enum(['parent', 'spouse', 'child', 'sibling', 'friend', 'other']),
|
|
34
|
+
phone: zod_1.default.string().regex(/^\d{10,11}$/),
|
|
35
|
+
priority: zod_1.default.number().min(1).max(3),
|
|
30
36
|
}).optional(),
|
|
31
37
|
});
|
|
32
|
-
const Address =
|
|
33
|
-
street:
|
|
34
|
-
number:
|
|
35
|
-
complement:
|
|
36
|
-
neighborhood:
|
|
37
|
-
city:
|
|
38
|
-
state:
|
|
39
|
-
cep:
|
|
40
|
-
country:
|
|
41
|
-
isPrimary:
|
|
42
|
-
type:
|
|
43
|
-
coordinates:
|
|
44
|
-
lat:
|
|
45
|
-
lng:
|
|
38
|
+
const Address = zod_1.default.object({
|
|
39
|
+
street: zod_1.default.string().min(3),
|
|
40
|
+
number: zod_1.default.string(),
|
|
41
|
+
complement: zod_1.default.string().optional(),
|
|
42
|
+
neighborhood: zod_1.default.string(),
|
|
43
|
+
city: zod_1.default.string(),
|
|
44
|
+
state: zod_1.default.string().length(2).regex(/^[A-Z]{2}$/),
|
|
45
|
+
cep: zod_1.default.string().regex(/^\d{8}$/),
|
|
46
|
+
country: zod_1.default.string().default('BR'),
|
|
47
|
+
isPrimary: zod_1.default.boolean().default(true),
|
|
48
|
+
type: zod_1.default.enum(['home', 'work', 'billing', 'shipping']),
|
|
49
|
+
coordinates: zod_1.default.object({
|
|
50
|
+
lat: zod_1.default.number().min(-90).max(90),
|
|
51
|
+
lng: zod_1.default.number().min(-180).max(180),
|
|
46
52
|
}).optional(),
|
|
47
53
|
});
|
|
48
|
-
const Geolocatable =
|
|
49
|
-
addresses:
|
|
50
|
-
timezone:
|
|
51
|
-
locale:
|
|
54
|
+
const Geolocatable = zod_1.default.object({
|
|
55
|
+
addresses: zod_1.default.array(Address).min(1).max(5),
|
|
56
|
+
timezone: zod_1.default.string().optional(),
|
|
57
|
+
locale: zod_1.default.string().default('pt-BR'),
|
|
52
58
|
});
|
|
53
|
-
const BankAccount =
|
|
54
|
-
bankCode:
|
|
55
|
-
agency:
|
|
56
|
-
account:
|
|
57
|
-
digit:
|
|
58
|
-
type:
|
|
59
|
-
isPrimary:
|
|
60
|
-
verifiedAt:
|
|
59
|
+
const BankAccount = zod_1.default.object({
|
|
60
|
+
bankCode: zod_1.default.string().regex(/^\d{3}$/),
|
|
61
|
+
agency: zod_1.default.string().regex(/^\d{4,5}$/),
|
|
62
|
+
account: zod_1.default.string().regex(/^\d{6,12}$/),
|
|
63
|
+
digit: zod_1.default.string().regex(/^[0-9X]$/),
|
|
64
|
+
type: zod_1.default.enum(['checking', 'savings', 'salary', 'payment']),
|
|
65
|
+
isPrimary: zod_1.default.boolean(),
|
|
66
|
+
verifiedAt: zod_1.default.date().optional(),
|
|
61
67
|
});
|
|
62
|
-
const FinancialInfo =
|
|
63
|
-
bankAccounts:
|
|
64
|
-
creditScore:
|
|
65
|
-
incomeRange:
|
|
66
|
-
taxId:
|
|
67
|
-
paymentMethods:
|
|
68
|
+
const FinancialInfo = zod_1.default.object({
|
|
69
|
+
bankAccounts: zod_1.default.array(BankAccount).max(3),
|
|
70
|
+
creditScore: zod_1.default.number().min(0).max(1000).optional(),
|
|
71
|
+
incomeRange: zod_1.default.enum(['A', 'B', 'C', 'D', 'E']).optional(),
|
|
72
|
+
taxId: zod_1.default.string().regex(/^\d{11}$|^\d{14}$/).optional(),
|
|
73
|
+
paymentMethods: zod_1.default.array(zod_1.default.enum(['credit_card', 'debit_card', 'pix', 'boleto', 'bank_transfer'])).min(1),
|
|
68
74
|
});
|
|
69
|
-
const Course =
|
|
70
|
-
id:
|
|
71
|
-
name:
|
|
72
|
-
code:
|
|
73
|
-
credits:
|
|
74
|
-
professorId:
|
|
75
|
-
schedule:
|
|
76
|
-
days:
|
|
77
|
-
startTime:
|
|
78
|
-
endTime:
|
|
79
|
-
room:
|
|
75
|
+
const Course = zod_1.default.object({
|
|
76
|
+
id: zod_1.default.string().regex(/^CRS\d{8}$/),
|
|
77
|
+
name: zod_1.default.string(),
|
|
78
|
+
code: zod_1.default.string().regex(/^[A-Z]{3}\d{3}$/),
|
|
79
|
+
credits: zod_1.default.number().int().min(1).max(12),
|
|
80
|
+
professorId: zod_1.default.uuid().optional(),
|
|
81
|
+
schedule: zod_1.default.object({
|
|
82
|
+
days: zod_1.default.array(zod_1.default.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'])).min(1).max(6),
|
|
83
|
+
startTime: zod_1.default.string().regex(/^\d{2}:\d{2}$/),
|
|
84
|
+
endTime: zod_1.default.string().regex(/^\d{2}:\d{2}$/),
|
|
85
|
+
room: zod_1.default.string().optional(),
|
|
80
86
|
}),
|
|
81
|
-
status:
|
|
87
|
+
status: zod_1.default.enum(['active', 'inactive', 'completed', 'cancelled']),
|
|
82
88
|
});
|
|
83
|
-
const AcademicRecord =
|
|
84
|
-
enrollmentId:
|
|
85
|
-
semester:
|
|
86
|
-
gpa:
|
|
87
|
-
totalCredits:
|
|
88
|
-
courses:
|
|
89
|
+
const AcademicRecord = zod_1.default.object({
|
|
90
|
+
enrollmentId: zod_1.default.string().regex(/^ENR\d{10}$/),
|
|
91
|
+
semester: zod_1.default.string().regex(/^\d{4}\.[12]$/),
|
|
92
|
+
gpa: zod_1.default.number().min(0).max(10).optional(),
|
|
93
|
+
totalCredits: zod_1.default.number().int().min(0),
|
|
94
|
+
courses: zod_1.default.array(zod_1.default.object({
|
|
89
95
|
course: Course,
|
|
90
|
-
grade:
|
|
91
|
-
status:
|
|
92
|
-
attendance:
|
|
96
|
+
grade: zod_1.default.number().min(0).max(10).optional(),
|
|
97
|
+
status: zod_1.default.enum(['enrolled', 'approved', 'failed', 'dropped']),
|
|
98
|
+
attendance: zod_1.default.number().min(0).max(100).optional(),
|
|
93
99
|
})).max(10),
|
|
94
100
|
});
|
|
95
|
-
const StudentRole =
|
|
96
|
-
type:
|
|
97
|
-
studentId:
|
|
98
|
-
enrollmentDate:
|
|
99
|
-
graduationDate:
|
|
101
|
+
const StudentRole = zod_1.default.object({
|
|
102
|
+
type: zod_1.default.literal('student'),
|
|
103
|
+
studentId: zod_1.default.string().regex(/^STU\d{8}$/),
|
|
104
|
+
enrollmentDate: zod_1.default.date(),
|
|
105
|
+
graduationDate: zod_1.default.date().optional(),
|
|
100
106
|
academicRecord: AcademicRecord,
|
|
101
|
-
scholarships:
|
|
102
|
-
id:
|
|
103
|
-
type:
|
|
104
|
-
amount:
|
|
105
|
-
startDate:
|
|
106
|
-
endDate:
|
|
107
|
-
renewable:
|
|
107
|
+
scholarships: zod_1.default.array(zod_1.default.object({
|
|
108
|
+
id: zod_1.default.string().regex(/^SCH\d{6}$/),
|
|
109
|
+
type: zod_1.default.enum(['merit', 'need', 'athletic', 'research']),
|
|
110
|
+
amount: zod_1.default.number().positive(),
|
|
111
|
+
startDate: zod_1.default.date(),
|
|
112
|
+
endDate: zod_1.default.date(),
|
|
113
|
+
renewable: zod_1.default.boolean(),
|
|
108
114
|
})).max(3).optional(),
|
|
109
|
-
campus:
|
|
115
|
+
campus: zod_1.default.enum(['main', 'north', 'south', 'online']),
|
|
110
116
|
});
|
|
111
|
-
const TeacherRole =
|
|
112
|
-
type:
|
|
113
|
-
employeeId:
|
|
114
|
-
hireDate:
|
|
115
|
-
department:
|
|
117
|
+
const TeacherRole = zod_1.default.object({
|
|
118
|
+
type: zod_1.default.literal('teacher'),
|
|
119
|
+
employeeId: zod_1.default.string().regex(/^TCH\d{8}$/),
|
|
120
|
+
hireDate: zod_1.default.date(),
|
|
121
|
+
department: zod_1.default.enum([
|
|
116
122
|
'computer_science', 'mathematics', 'physics', 'chemistry',
|
|
117
123
|
'biology', 'engineering', 'business', 'arts', 'law', 'medicine'
|
|
118
124
|
]),
|
|
119
|
-
title:
|
|
120
|
-
salary:
|
|
121
|
-
base:
|
|
122
|
-
currency:
|
|
123
|
-
paymentSchedule:
|
|
124
|
-
benefits:
|
|
125
|
+
title: zod_1.default.enum(['assistant', 'associate', 'full', 'adjunct', 'visiting']),
|
|
126
|
+
salary: zod_1.default.object({
|
|
127
|
+
base: zod_1.default.number().positive(),
|
|
128
|
+
currency: zod_1.default.string().default('BRL'),
|
|
129
|
+
paymentSchedule: zod_1.default.enum(['monthly', 'biweekly', 'weekly']),
|
|
130
|
+
benefits: zod_1.default.array(zod_1.default.enum(['health', 'dental', 'vision', 'retirement', 'tuition'])).optional(),
|
|
125
131
|
}),
|
|
126
|
-
officeHours:
|
|
127
|
-
day:
|
|
128
|
-
start:
|
|
129
|
-
end:
|
|
130
|
-
location:
|
|
131
|
-
mode:
|
|
132
|
+
officeHours: zod_1.default.array(zod_1.default.object({
|
|
133
|
+
day: zod_1.default.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday']),
|
|
134
|
+
start: zod_1.default.string().regex(/^\d{2}:\d{2}$/),
|
|
135
|
+
end: zod_1.default.string().regex(/^\d{2}:\d{2}$/),
|
|
136
|
+
location: zod_1.default.string(),
|
|
137
|
+
mode: zod_1.default.enum(['in_person', 'virtual', 'hybrid']),
|
|
132
138
|
})).max(5).optional(),
|
|
133
|
-
coursesTeaching:
|
|
139
|
+
coursesTeaching: zod_1.default.array(zod_1.default.object({
|
|
134
140
|
course: Course,
|
|
135
|
-
semester:
|
|
136
|
-
section:
|
|
141
|
+
semester: zod_1.default.string().regex(/^\d{4}\.[12]$/),
|
|
142
|
+
section: zod_1.default.string().regex(/^[A-Z]$/),
|
|
137
143
|
})).max(4),
|
|
138
144
|
});
|
|
139
|
-
const AdminRole =
|
|
140
|
-
type:
|
|
141
|
-
employeeId:
|
|
142
|
-
hireDate:
|
|
143
|
-
department:
|
|
145
|
+
const AdminRole = zod_1.default.object({
|
|
146
|
+
type: zod_1.default.literal('admin'),
|
|
147
|
+
employeeId: zod_1.default.string().regex(/^ADM\d{8}$/),
|
|
148
|
+
hireDate: zod_1.default.date(),
|
|
149
|
+
department: zod_1.default.enum([
|
|
144
150
|
'human_resources', 'information_technology', 'finance',
|
|
145
151
|
'operations', 'admissions', 'student_affairs', 'facilities'
|
|
146
152
|
]),
|
|
147
|
-
level:
|
|
148
|
-
permissions:
|
|
149
|
-
resource:
|
|
153
|
+
level: zod_1.default.number().min(1).max(10),
|
|
154
|
+
permissions: zod_1.default.array(zod_1.default.object({
|
|
155
|
+
resource: zod_1.default.enum([
|
|
150
156
|
'users', 'courses', 'enrollments', 'grades', 'payments',
|
|
151
157
|
'reports', 'settings', 'audit_logs', 'notifications'
|
|
152
158
|
]),
|
|
153
|
-
actions:
|
|
154
|
-
scope:
|
|
159
|
+
actions: zod_1.default.array(zod_1.default.enum(['read', 'create', 'update', 'delete', 'approve', 'export'])).min(1),
|
|
160
|
+
scope: zod_1.default.enum(['global', 'department', 'personal']),
|
|
155
161
|
})).min(1),
|
|
156
|
-
reportsTo:
|
|
157
|
-
managedDepartments:
|
|
162
|
+
reportsTo: zod_1.default.uuid().optional(),
|
|
163
|
+
managedDepartments: zod_1.default.array(zod_1.default.string()).optional(),
|
|
158
164
|
});
|
|
159
|
-
const StaffRole =
|
|
160
|
-
type:
|
|
161
|
-
employeeId:
|
|
162
|
-
hireDate:
|
|
163
|
-
position:
|
|
165
|
+
const StaffRole = zod_1.default.object({
|
|
166
|
+
type: zod_1.default.literal('staff'),
|
|
167
|
+
employeeId: zod_1.default.string().regex(/^STF\d{8}$/),
|
|
168
|
+
hireDate: zod_1.default.date(),
|
|
169
|
+
position: zod_1.default.enum([
|
|
164
170
|
'librarian', 'technician', 'counselor', 'coordinator',
|
|
165
171
|
'assistant', 'specialist', 'analyst', 'supervisor'
|
|
166
172
|
]),
|
|
167
|
-
department:
|
|
168
|
-
schedule:
|
|
169
|
-
workHours:
|
|
170
|
-
shift:
|
|
171
|
-
remoteDays:
|
|
173
|
+
department: zod_1.default.string(),
|
|
174
|
+
schedule: zod_1.default.object({
|
|
175
|
+
workHours: zod_1.default.number().min(20).max(60),
|
|
176
|
+
shift: zod_1.default.enum(['morning', 'afternoon', 'night', 'flexible']),
|
|
177
|
+
remoteDays: zod_1.default.array(zod_1.default.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])).max(3).optional(),
|
|
172
178
|
}),
|
|
173
179
|
});
|
|
174
|
-
const PersonRole =
|
|
180
|
+
const PersonRole = zod_1.default.discriminatedUnion('type', [
|
|
175
181
|
StudentRole,
|
|
176
182
|
TeacherRole,
|
|
177
183
|
AdminRole,
|
|
178
184
|
StaffRole,
|
|
179
185
|
]);
|
|
180
|
-
const IdentityDocument =
|
|
181
|
-
type:
|
|
182
|
-
number:
|
|
183
|
-
issuingAuthority:
|
|
184
|
-
issueDate:
|
|
185
|
-
expiryDate:
|
|
186
|
-
photoUrl:
|
|
187
|
-
verified:
|
|
186
|
+
const IdentityDocument = zod_1.default.object({
|
|
187
|
+
type: zod_1.default.literal('id_card'),
|
|
188
|
+
number: zod_1.default.string().regex(/^[A-Z0-9]{5,20}$/),
|
|
189
|
+
issuingAuthority: zod_1.default.string(),
|
|
190
|
+
issueDate: zod_1.default.date(),
|
|
191
|
+
expiryDate: zod_1.default.date().optional(),
|
|
192
|
+
photoUrl: zod_1.default.url().optional(),
|
|
193
|
+
verified: zod_1.default.boolean().default(false),
|
|
188
194
|
});
|
|
189
|
-
const PassportDocument =
|
|
190
|
-
type:
|
|
191
|
-
number:
|
|
192
|
-
country:
|
|
193
|
-
nationality:
|
|
194
|
-
issueDate:
|
|
195
|
-
expiryDate:
|
|
196
|
-
visaInfo:
|
|
197
|
-
country:
|
|
198
|
-
type:
|
|
199
|
-
issueDate:
|
|
200
|
-
expiryDate:
|
|
195
|
+
const PassportDocument = zod_1.default.object({
|
|
196
|
+
type: zod_1.default.literal('passport'),
|
|
197
|
+
number: zod_1.default.string().regex(/^[A-Z0-9]{8,12}$/),
|
|
198
|
+
country: zod_1.default.string().length(3),
|
|
199
|
+
nationality: zod_1.default.string(),
|
|
200
|
+
issueDate: zod_1.default.date(),
|
|
201
|
+
expiryDate: zod_1.default.date(),
|
|
202
|
+
visaInfo: zod_1.default.array(zod_1.default.object({
|
|
203
|
+
country: zod_1.default.string().length(3),
|
|
204
|
+
type: zod_1.default.string(),
|
|
205
|
+
issueDate: zod_1.default.date(),
|
|
206
|
+
expiryDate: zod_1.default.date(),
|
|
201
207
|
})).max(5).optional(),
|
|
202
208
|
});
|
|
203
|
-
const ProfessionalDocument =
|
|
204
|
-
type:
|
|
205
|
-
number:
|
|
206
|
-
category:
|
|
207
|
-
council:
|
|
208
|
-
state:
|
|
209
|
-
validity:
|
|
209
|
+
const ProfessionalDocument = zod_1.default.object({
|
|
210
|
+
type: zod_1.default.literal('professional'),
|
|
211
|
+
number: zod_1.default.string().regex(/^[A-Z0-9]{5,15}$/),
|
|
212
|
+
category: zod_1.default.string(),
|
|
213
|
+
council: zod_1.default.string(),
|
|
214
|
+
state: zod_1.default.string().length(2),
|
|
215
|
+
validity: zod_1.default.date(),
|
|
210
216
|
});
|
|
211
|
-
const Documents =
|
|
212
|
-
const HealthInfo =
|
|
213
|
-
bloodType:
|
|
214
|
-
allergies:
|
|
215
|
-
medications:
|
|
216
|
-
name:
|
|
217
|
-
dosage:
|
|
218
|
-
frequency:
|
|
219
|
-
prescribedBy:
|
|
217
|
+
const Documents = zod_1.default.array(zod_1.default.union([IdentityDocument, PassportDocument, ProfessionalDocument])).max(5).optional();
|
|
218
|
+
const HealthInfo = zod_1.default.object({
|
|
219
|
+
bloodType: zod_1.default.enum(['A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-']).optional(),
|
|
220
|
+
allergies: zod_1.default.array(zod_1.default.string()).max(20).optional(),
|
|
221
|
+
medications: zod_1.default.array(zod_1.default.object({
|
|
222
|
+
name: zod_1.default.string(),
|
|
223
|
+
dosage: zod_1.default.string(),
|
|
224
|
+
frequency: zod_1.default.string(),
|
|
225
|
+
prescribedBy: zod_1.default.string().optional(),
|
|
220
226
|
})).max(10).optional(),
|
|
221
|
-
disabilities:
|
|
222
|
-
type:
|
|
223
|
-
description:
|
|
224
|
-
accommodations:
|
|
227
|
+
disabilities: zod_1.default.array(zod_1.default.object({
|
|
228
|
+
type: zod_1.default.string(),
|
|
229
|
+
description: zod_1.default.string(),
|
|
230
|
+
accommodations: zod_1.default.array(zod_1.default.string()).optional(),
|
|
225
231
|
})).max(5).optional(),
|
|
226
|
-
emergencyMedicalContacts:
|
|
227
|
-
name:
|
|
228
|
-
relationship:
|
|
229
|
-
phone:
|
|
230
|
-
priority:
|
|
232
|
+
emergencyMedicalContacts: zod_1.default.array(zod_1.default.object({
|
|
233
|
+
name: zod_1.default.string(),
|
|
234
|
+
relationship: zod_1.default.string(),
|
|
235
|
+
phone: zod_1.default.string().regex(/^\d{10,11}$/),
|
|
236
|
+
priority: zod_1.default.number().min(1).max(3),
|
|
231
237
|
})).max(3).optional(),
|
|
232
238
|
});
|
|
233
|
-
const Preferences =
|
|
234
|
-
notification:
|
|
235
|
-
email:
|
|
236
|
-
sms:
|
|
237
|
-
push:
|
|
238
|
-
digest:
|
|
239
|
+
const Preferences = zod_1.default.object({
|
|
240
|
+
notification: zod_1.default.object({
|
|
241
|
+
email: zod_1.default.boolean().default(true),
|
|
242
|
+
sms: zod_1.default.boolean().default(false),
|
|
243
|
+
push: zod_1.default.boolean().default(true),
|
|
244
|
+
digest: zod_1.default.enum(['daily', 'weekly', 'monthly', 'never']).default('weekly'),
|
|
239
245
|
}),
|
|
240
|
-
privacy:
|
|
241
|
-
profileVisible:
|
|
242
|
-
searchable:
|
|
243
|
-
showEmail:
|
|
244
|
-
showPhone:
|
|
245
|
-
dataSharing:
|
|
246
|
+
privacy: zod_1.default.object({
|
|
247
|
+
profileVisible: zod_1.default.boolean().default(true),
|
|
248
|
+
searchable: zod_1.default.boolean().default(true),
|
|
249
|
+
showEmail: zod_1.default.boolean().default(false),
|
|
250
|
+
showPhone: zod_1.default.boolean().default(false),
|
|
251
|
+
dataSharing: zod_1.default.enum(['none', 'essential', 'all']).default('essential'),
|
|
246
252
|
}),
|
|
247
|
-
language:
|
|
248
|
-
timeFormat:
|
|
249
|
-
dateFormat:
|
|
253
|
+
language: zod_1.default.string().default('pt-BR'),
|
|
254
|
+
timeFormat: zod_1.default.enum(['12h', '24h']).default('24h'),
|
|
255
|
+
dateFormat: zod_1.default.enum(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD']).default('DD/MM/YYYY'),
|
|
250
256
|
});
|
|
251
|
-
const StatusHistory =
|
|
252
|
-
status:
|
|
253
|
-
effectiveDate:
|
|
254
|
-
reason:
|
|
255
|
-
changedBy:
|
|
257
|
+
const StatusHistory = zod_1.default.array(zod_1.default.object({
|
|
258
|
+
status: zod_1.default.enum(['active', 'inactive', 'pending', 'suspended', 'graduated', 'terminated']),
|
|
259
|
+
effectiveDate: zod_1.default.date(),
|
|
260
|
+
reason: zod_1.default.string().optional(),
|
|
261
|
+
changedBy: zod_1.default.uuid().optional(),
|
|
256
262
|
})).min(1);
|
|
257
|
-
const StudentMetadata =
|
|
258
|
-
advisorId:
|
|
259
|
-
thesisTitle:
|
|
260
|
-
researchArea:
|
|
261
|
-
publications:
|
|
262
|
-
title:
|
|
263
|
-
year:
|
|
264
|
-
venue:
|
|
263
|
+
const StudentMetadata = zod_1.default.object({
|
|
264
|
+
advisorId: zod_1.default.uuid().optional(),
|
|
265
|
+
thesisTitle: zod_1.default.string().optional(),
|
|
266
|
+
researchArea: zod_1.default.string().optional(),
|
|
267
|
+
publications: zod_1.default.array(zod_1.default.object({
|
|
268
|
+
title: zod_1.default.string(),
|
|
269
|
+
year: zod_1.default.number().int().min(2000).max(2030),
|
|
270
|
+
venue: zod_1.default.string().optional(),
|
|
265
271
|
})).max(20).optional(),
|
|
266
272
|
});
|
|
267
|
-
const TeacherMetadata =
|
|
268
|
-
researchInterests:
|
|
269
|
-
publicationsCount:
|
|
270
|
-
grants:
|
|
271
|
-
id:
|
|
272
|
-
title:
|
|
273
|
-
fundingAgency:
|
|
274
|
-
amount:
|
|
275
|
-
period:
|
|
273
|
+
const TeacherMetadata = zod_1.default.object({
|
|
274
|
+
researchInterests: zod_1.default.array(zod_1.default.string()).max(10).optional(),
|
|
275
|
+
publicationsCount: zod_1.default.number().int().min(0),
|
|
276
|
+
grants: zod_1.default.array(zod_1.default.object({
|
|
277
|
+
id: zod_1.default.string(),
|
|
278
|
+
title: zod_1.default.string(),
|
|
279
|
+
fundingAgency: zod_1.default.string(),
|
|
280
|
+
amount: zod_1.default.number().positive(),
|
|
281
|
+
period: zod_1.default.string(),
|
|
276
282
|
})).max(10).optional(),
|
|
277
|
-
officeLocation:
|
|
283
|
+
officeLocation: zod_1.default.string(),
|
|
278
284
|
});
|
|
279
|
-
const AdminMetadata =
|
|
280
|
-
budgetResponsibility:
|
|
281
|
-
teamSize:
|
|
282
|
-
projects:
|
|
283
|
-
name:
|
|
284
|
-
status:
|
|
285
|
-
deadline:
|
|
285
|
+
const AdminMetadata = zod_1.default.object({
|
|
286
|
+
budgetResponsibility: zod_1.default.number().positive().optional(),
|
|
287
|
+
teamSize: zod_1.default.number().int().min(0),
|
|
288
|
+
projects: zod_1.default.array(zod_1.default.object({
|
|
289
|
+
name: zod_1.default.string(),
|
|
290
|
+
status: zod_1.default.enum(['planning', 'active', 'completed', 'cancelled']),
|
|
291
|
+
deadline: zod_1.default.date().optional(),
|
|
286
292
|
})).max(10).optional(),
|
|
287
293
|
});
|
|
288
|
-
const Metadata =
|
|
294
|
+
const Metadata = zod_1.default.union([
|
|
289
295
|
StudentMetadata,
|
|
290
296
|
TeacherMetadata,
|
|
291
297
|
AdminMetadata,
|
|
292
298
|
]);
|
|
293
|
-
|
|
294
|
-
name:
|
|
295
|
-
firstName:
|
|
296
|
-
lastName:
|
|
297
|
-
middleName:
|
|
298
|
-
preferredName:
|
|
299
|
-
title:
|
|
299
|
+
exports.PersonEntitySchema = zod_1.default.object({
|
|
300
|
+
name: zod_1.default.object({
|
|
301
|
+
firstName: zod_1.default.string().min(2).max(50),
|
|
302
|
+
lastName: zod_1.default.string().min(2).max(50),
|
|
303
|
+
middleName: zod_1.default.string().optional(),
|
|
304
|
+
preferredName: zod_1.default.string().optional(),
|
|
305
|
+
title: zod_1.default.enum(['Mr.', 'Mrs.', 'Ms.', 'Dr.', 'Prof.']).optional(),
|
|
300
306
|
}),
|
|
301
|
-
demographic:
|
|
302
|
-
birthDate:
|
|
303
|
-
age:
|
|
304
|
-
gender:
|
|
305
|
-
nationality:
|
|
306
|
-
maritalStatus:
|
|
307
|
+
demographic: zod_1.default.object({
|
|
308
|
+
birthDate: zod_1.default.date(),
|
|
309
|
+
age: zod_1.default.number().int().min(0).max(120),
|
|
310
|
+
gender: zod_1.default.enum(['male', 'female', 'non_binary', 'prefer_not_to_say']),
|
|
311
|
+
nationality: zod_1.default.string(),
|
|
312
|
+
maritalStatus: zod_1.default.enum(['single', 'married', 'divorced', 'widowed']).optional(),
|
|
307
313
|
}),
|
|
308
|
-
officialDocuments:
|
|
309
|
-
cpf:
|
|
310
|
-
rg:
|
|
311
|
-
pis:
|
|
312
|
-
voterId:
|
|
314
|
+
officialDocuments: zod_1.default.object({
|
|
315
|
+
cpf: zod_1.default.string().regex(/^\d{11}$/),
|
|
316
|
+
rg: zod_1.default.string().regex(/^\d{7,9}$/),
|
|
317
|
+
pis: zod_1.default.string().regex(/^\d{11}$/).optional(),
|
|
318
|
+
voterId: zod_1.default.string().regex(/^\d{12}$/).optional(),
|
|
313
319
|
}),
|
|
314
320
|
role: PersonRole,
|
|
315
|
-
status:
|
|
321
|
+
status: zod_1.default.enum(['active', 'inactive', 'pending', 'suspended', 'graduated', 'terminated']),
|
|
316
322
|
statusHistory: StatusHistory,
|
|
317
|
-
emergencyContacts:
|
|
318
|
-
name:
|
|
319
|
-
phone:
|
|
320
|
-
relationship:
|
|
321
|
-
priority:
|
|
322
|
-
availableHours:
|
|
323
|
+
emergencyContacts: zod_1.default.array(zod_1.default.object({
|
|
324
|
+
name: zod_1.default.string(),
|
|
325
|
+
phone: zod_1.default.string().regex(/^\d{10,11}$/),
|
|
326
|
+
relationship: zod_1.default.enum(['parent', 'spouse', 'child', 'sibling', 'friend', 'other']),
|
|
327
|
+
priority: zod_1.default.number().min(1).max(3),
|
|
328
|
+
availableHours: zod_1.default.string().optional(),
|
|
323
329
|
})).min(1).max(5),
|
|
324
330
|
documents: Documents,
|
|
325
331
|
contactInfo: ContactInfo,
|
|
326
|
-
addresses:
|
|
332
|
+
addresses: zod_1.default.array(Address).min(1).max(3),
|
|
327
333
|
financialInfo: FinancialInfo.optional(),
|
|
328
334
|
healthInfo: HealthInfo.optional(),
|
|
329
335
|
preferences: Preferences,
|
|
330
336
|
roleSpecificMetadata: Metadata.optional(),
|
|
331
|
-
academicHistory:
|
|
332
|
-
system:
|
|
333
|
-
isVerified:
|
|
334
|
-
verificationLevel:
|
|
335
|
-
lastLogin:
|
|
336
|
-
loginCount:
|
|
337
|
-
tags:
|
|
338
|
-
flags:
|
|
337
|
+
academicHistory: zod_1.default.array(AcademicRecord).max(10).optional(),
|
|
338
|
+
system: zod_1.default.object({
|
|
339
|
+
isVerified: zod_1.default.boolean().default(false),
|
|
340
|
+
verificationLevel: zod_1.default.number().min(0).max(3).default(0),
|
|
341
|
+
lastLogin: zod_1.default.date().optional(),
|
|
342
|
+
loginCount: zod_1.default.number().int().min(0).default(0),
|
|
343
|
+
tags: zod_1.default.array(zod_1.default.string()).max(20).optional(),
|
|
344
|
+
flags: zod_1.default.array(zod_1.default.enum(['high_value', 'at_risk', 'vip', 'fraud_risk', 'legacy'])).optional(),
|
|
339
345
|
}),
|
|
340
346
|
}).and(Identifiable).and(Auditable);
|
|
341
347
|
describe('PersonEntity with Complex Schema', () => {
|
|
342
|
-
const entityMock = new ZodMockSchema(PersonEntitySchema);
|
|
348
|
+
const entityMock = new zod_mock_schema_js_1.ZodMockSchema(exports.PersonEntitySchema);
|
|
343
349
|
test('should generate complex mock data', () => {
|
|
344
350
|
const mock = entityMock.generate();
|
|
345
351
|
expect(mock).toBeDefined();
|
|
@@ -351,15 +357,15 @@ describe('PersonEntity with Complex Schema', () => {
|
|
|
351
357
|
describe('New Zod Types Support', () => {
|
|
352
358
|
describe('ZodSet', () => {
|
|
353
359
|
test('should generate a Set with elements', () => {
|
|
354
|
-
const schema =
|
|
355
|
-
const mock = new ZodMockSchema(schema);
|
|
360
|
+
const schema = zod_1.default.set(zod_1.default.string());
|
|
361
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
356
362
|
const result = mock.generate();
|
|
357
363
|
expect(result).toBeInstanceOf(Set);
|
|
358
364
|
expect(result.size).toBeGreaterThan(0);
|
|
359
365
|
});
|
|
360
366
|
test('should respect min/max size constraints', () => {
|
|
361
|
-
const schema =
|
|
362
|
-
const mock = new ZodMockSchema(schema);
|
|
367
|
+
const schema = zod_1.default.set(zod_1.default.number()).min(2).max(5);
|
|
368
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
363
369
|
const result = mock.generate();
|
|
364
370
|
expect(result).toBeInstanceOf(Set);
|
|
365
371
|
expect(result.size).toBeGreaterThanOrEqual(2);
|
|
@@ -368,8 +374,8 @@ describe('New Zod Types Support', () => {
|
|
|
368
374
|
});
|
|
369
375
|
describe('ZodMap', () => {
|
|
370
376
|
test('should generate a Map with entries', () => {
|
|
371
|
-
const schema =
|
|
372
|
-
const mock = new ZodMockSchema(schema);
|
|
377
|
+
const schema = zod_1.default.map(zod_1.default.string(), zod_1.default.number());
|
|
378
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
373
379
|
const result = mock.generate();
|
|
374
380
|
expect(result).toBeInstanceOf(Map);
|
|
375
381
|
expect(result.size).toBeGreaterThan(0);
|
|
@@ -377,8 +383,8 @@ describe('New Zod Types Support', () => {
|
|
|
377
383
|
});
|
|
378
384
|
describe('ZodTuple', () => {
|
|
379
385
|
test('should generate a tuple with correct types', () => {
|
|
380
|
-
const schema =
|
|
381
|
-
const mock = new ZodMockSchema(schema);
|
|
386
|
+
const schema = zod_1.default.tuple([zod_1.default.string(), zod_1.default.number(), zod_1.default.boolean()]);
|
|
387
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
382
388
|
const result = mock.generate();
|
|
383
389
|
expect(Array.isArray(result)).toBe(true);
|
|
384
390
|
expect(result).toHaveLength(3);
|
|
@@ -387,8 +393,8 @@ describe('New Zod Types Support', () => {
|
|
|
387
393
|
expect(typeof result[2]).toBe('boolean');
|
|
388
394
|
});
|
|
389
395
|
test('should generate tuple with rest elements', () => {
|
|
390
|
-
const schema =
|
|
391
|
-
const mock = new ZodMockSchema(schema);
|
|
396
|
+
const schema = zod_1.default.tuple([zod_1.default.string()]).rest(zod_1.default.number());
|
|
397
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
392
398
|
const result = mock.generate();
|
|
393
399
|
expect(Array.isArray(result)).toBe(true);
|
|
394
400
|
expect(result.length).toBeGreaterThanOrEqual(1);
|
|
@@ -397,8 +403,8 @@ describe('New Zod Types Support', () => {
|
|
|
397
403
|
});
|
|
398
404
|
describe('ZodFunction', () => {
|
|
399
405
|
test('should generate a function that returns mocked value', () => {
|
|
400
|
-
const schema =
|
|
401
|
-
const mock = new ZodMockSchema(schema);
|
|
406
|
+
const schema = zod_1.default.function();
|
|
407
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
402
408
|
const result = mock.generate();
|
|
403
409
|
expect(typeof result).toBe('function');
|
|
404
410
|
expect(result).toBeDefined();
|
|
@@ -406,11 +412,11 @@ describe('New Zod Types Support', () => {
|
|
|
406
412
|
});
|
|
407
413
|
describe('ZodDiscriminatedUnion', () => {
|
|
408
414
|
test('should generate one of the union options', () => {
|
|
409
|
-
const schema =
|
|
410
|
-
|
|
411
|
-
|
|
415
|
+
const schema = zod_1.default.discriminatedUnion('type', [
|
|
416
|
+
zod_1.default.object({ type: zod_1.default.literal('a'), value: zod_1.default.string() }),
|
|
417
|
+
zod_1.default.object({ type: zod_1.default.literal('b'), value: zod_1.default.number() }),
|
|
412
418
|
]);
|
|
413
|
-
const mock = new ZodMockSchema(schema);
|
|
419
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
414
420
|
const result = mock.generate();
|
|
415
421
|
expect(result).toBeDefined();
|
|
416
422
|
expect(['a', 'b']).toContain(result.type);
|
|
@@ -418,8 +424,8 @@ describe('New Zod Types Support', () => {
|
|
|
418
424
|
});
|
|
419
425
|
describe('ZodBigInt', () => {
|
|
420
426
|
test('should generate a BigInt', () => {
|
|
421
|
-
const schema =
|
|
422
|
-
const mock = new ZodMockSchema(schema);
|
|
427
|
+
const schema = zod_1.default.bigint();
|
|
428
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
423
429
|
const result = mock.generate();
|
|
424
430
|
expect(typeof result).toBe('bigint');
|
|
425
431
|
expect(result).toBeGreaterThan(BigInt(0));
|
|
@@ -427,16 +433,16 @@ describe('New Zod Types Support', () => {
|
|
|
427
433
|
});
|
|
428
434
|
describe('ZodNaN', () => {
|
|
429
435
|
test('should generate NaN', () => {
|
|
430
|
-
const schema =
|
|
431
|
-
const mock = new ZodMockSchema(schema);
|
|
436
|
+
const schema = zod_1.default.nan();
|
|
437
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
432
438
|
const result = mock.generate();
|
|
433
439
|
expect(Number.isNaN(result)).toBe(true);
|
|
434
440
|
});
|
|
435
441
|
});
|
|
436
442
|
describe('ZodReadonly', () => {
|
|
437
443
|
test('should generate readonly object', () => {
|
|
438
|
-
const schema =
|
|
439
|
-
const mock = new ZodMockSchema(schema);
|
|
444
|
+
const schema = zod_1.default.object({ name: zod_1.default.string() }).readonly();
|
|
445
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
440
446
|
const result = mock.generate();
|
|
441
447
|
expect(result).toBeDefined();
|
|
442
448
|
expect(typeof result.name).toBe('string');
|
|
@@ -446,20 +452,20 @@ describe('New Zod Types Support', () => {
|
|
|
446
452
|
describe('Improved Constraints', () => {
|
|
447
453
|
describe('String min/max', () => {
|
|
448
454
|
test('should respect min length', () => {
|
|
449
|
-
const schema =
|
|
450
|
-
const mock = new ZodMockSchema(schema);
|
|
455
|
+
const schema = zod_1.default.string().min(10);
|
|
456
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
451
457
|
const result = mock.generate();
|
|
452
458
|
expect(result.length).toBeGreaterThanOrEqual(10);
|
|
453
459
|
});
|
|
454
460
|
test('should respect max length', () => {
|
|
455
|
-
const schema =
|
|
456
|
-
const mock = new ZodMockSchema(schema);
|
|
461
|
+
const schema = zod_1.default.string().max(5);
|
|
462
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
457
463
|
const result = mock.generate();
|
|
458
464
|
expect(result.length).toBeLessThanOrEqual(5);
|
|
459
465
|
});
|
|
460
466
|
test('should respect both min and max', () => {
|
|
461
|
-
const schema =
|
|
462
|
-
const mock = new ZodMockSchema(schema);
|
|
467
|
+
const schema = zod_1.default.string().min(5).max(10);
|
|
468
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
463
469
|
const result = mock.generate();
|
|
464
470
|
expect(result.length).toBeGreaterThanOrEqual(5);
|
|
465
471
|
expect(result.length).toBeLessThanOrEqual(10);
|
|
@@ -469,8 +475,8 @@ describe('Improved Constraints', () => {
|
|
|
469
475
|
test('should respect date range', () => {
|
|
470
476
|
const minDate = new Date('2025-01-01');
|
|
471
477
|
const maxDate = new Date('2025-12-31');
|
|
472
|
-
const schema =
|
|
473
|
-
const mock = new ZodMockSchema(schema);
|
|
478
|
+
const schema = zod_1.default.date().min(minDate).max(maxDate);
|
|
479
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
474
480
|
const result = mock.generate();
|
|
475
481
|
expect(result).toBeInstanceOf(Date);
|
|
476
482
|
expect(result.getTime()).toBeGreaterThanOrEqual(minDate.getTime());
|
|
@@ -479,14 +485,14 @@ describe('Improved Constraints', () => {
|
|
|
479
485
|
});
|
|
480
486
|
describe('ZodDefault always uses default value', () => {
|
|
481
487
|
test('should always return the default value', () => {
|
|
482
|
-
const schema =
|
|
483
|
-
const mock = new ZodMockSchema(schema);
|
|
488
|
+
const schema = zod_1.default.string().default('DEFAULT_VALUE');
|
|
489
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
484
490
|
const results = Array.from({ length: 10 }, () => mock.generate());
|
|
485
491
|
expect(results.every(r => r === 'DEFAULT_VALUE')).toBe(true);
|
|
486
492
|
});
|
|
487
493
|
test('should work with default numbers', () => {
|
|
488
|
-
const schema =
|
|
489
|
-
const mock = new ZodMockSchema(schema);
|
|
494
|
+
const schema = zod_1.default.number().default(42);
|
|
495
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema);
|
|
490
496
|
const result = mock.generate();
|
|
491
497
|
expect(result).toBe(42);
|
|
492
498
|
});
|
|
@@ -494,31 +500,31 @@ describe('Improved Constraints', () => {
|
|
|
494
500
|
});
|
|
495
501
|
describe('Seed Support', () => {
|
|
496
502
|
test('should generate same data with same seed', () => {
|
|
497
|
-
const schema =
|
|
498
|
-
name:
|
|
499
|
-
age:
|
|
500
|
-
email:
|
|
503
|
+
const schema = zod_1.default.object({
|
|
504
|
+
name: zod_1.default.string(),
|
|
505
|
+
age: zod_1.default.number(),
|
|
506
|
+
email: zod_1.default.email(),
|
|
501
507
|
});
|
|
502
|
-
const mock1 = new ZodMockSchema(schema).seed(12345);
|
|
508
|
+
const mock1 = new zod_mock_schema_js_1.ZodMockSchema(schema).seed(12345);
|
|
503
509
|
const result1 = mock1.generate();
|
|
504
|
-
const mock2 = new ZodMockSchema(schema).seed(12345);
|
|
510
|
+
const mock2 = new zod_mock_schema_js_1.ZodMockSchema(schema).seed(12345);
|
|
505
511
|
const result2 = mock2.generate();
|
|
506
512
|
expect(result1).toEqual(result2);
|
|
507
513
|
});
|
|
508
514
|
test('should generate different data with different seeds', () => {
|
|
509
|
-
const schema =
|
|
510
|
-
name:
|
|
511
|
-
age:
|
|
515
|
+
const schema = zod_1.default.object({
|
|
516
|
+
name: zod_1.default.string(),
|
|
517
|
+
age: zod_1.default.number(),
|
|
512
518
|
});
|
|
513
|
-
const mock1 = new ZodMockSchema(schema).seed(111);
|
|
519
|
+
const mock1 = new zod_mock_schema_js_1.ZodMockSchema(schema).seed(111);
|
|
514
520
|
const result1 = mock1.generate();
|
|
515
|
-
const mock2 = new ZodMockSchema(schema).seed(222);
|
|
521
|
+
const mock2 = new zod_mock_schema_js_1.ZodMockSchema(schema).seed(222);
|
|
516
522
|
const result2 = mock2.generate();
|
|
517
523
|
expect(result1).not.toEqual(result2);
|
|
518
524
|
});
|
|
519
525
|
test('should support array seed', () => {
|
|
520
|
-
const schema =
|
|
521
|
-
const mock = new ZodMockSchema(schema).seed([1, 2, 3]);
|
|
526
|
+
const schema = zod_1.default.string();
|
|
527
|
+
const mock = new zod_mock_schema_js_1.ZodMockSchema(schema).seed([1, 2, 3]);
|
|
522
528
|
const result = mock.generate();
|
|
523
529
|
expect(typeof result).toBe('string');
|
|
524
530
|
});
|