-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for simple object pattern in schema #356
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #356 +/- ##
==========================================
- Coverage 98.67% 98.45% -0.22%
==========================================
Files 9 9
Lines 529 519 -10
Branches 203 199 -4
==========================================
- Hits 522 511 -11
- Misses 7 8 +1
☔ View full report in Codecov by Sentry. |
Looks good, a few people are going to be happy with this |
@@ -65,28 +65,6 @@ export interface TestSchema { | |||
}`); | |||
}); | |||
|
|||
test('`pattern(Joi.string(), Joi.number())`', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if these removed tests are kept? this may cause regression for some people
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrjono1
There are the following problems with supporting old tests:
FAIL src/__tests__/unknown.ts (11.936 s)
● test `Joi.unknown()` › `pattern(Joi.string(), Joi.number())`
expect(received).toBe(expected) // Object.is equality
- Expected - 4
+ Received + 1
/**
* a test schema definition
*/
export interface TestSchema {
name?: string;
- /**
- * Number Property
- */
- [x: string]: number;
+ [pattern: string]: number;
}
76 | const result = convertSchema({ sortPropertiesByName: false }, schema);
77 | expect(result).not.toBeUndefined;
> 78 | expect(result?.content).toBe(`/**
| ^
79 | * a test schema definition
80 | */
81 | export interface TestSchema {
at Object.<anonymous> (src/__tests__/unknown.ts:78:29)
● test `Joi.unknown()` › `pattern(Joi.string(), Joi.AnySchema())`
expect(received).toBe(expected) // Object.is equality
- Expected - 1
+ Received + 1
/**
* a test schema definition
*/
export interface TestSchema {
- [x: string]: {
+ [pattern: string]: {
id: string;
}[];
}
123 | const result = convertSchema({}, schema);
124 | expect(result).not.toBeUndefined;
> 125 | expect(result?.content).toBe(`/**
| ^
126 | * a test schema definition
127 | */
128 | export interface TestSchema {
at Object.<anonymous> (src/__tests__/unknown.ts:125:29)
Patterns change this generation logic and we get a new output schema
Related issues: #351 #352