Skip to content

Commit 004fd40

Browse files
author
Pontus Lundin
committed
add tests
1 parent 234d304 commit 004fd40

File tree

1 file changed

+45
-0
lines changed
  • packages/openapi-typescript/test/transform/schema-object

1 file changed

+45
-0
lines changed

packages/openapi-typescript/test/transform/schema-object/object.test.ts

+45
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,51 @@ describe("transformSchemaObject > object", () => {
9999
// options: DEFAULT_OPTIONS,
100100
},
101101
],
102+
[
103+
"patternProperties > empty object",
104+
{
105+
given: { type: "object", patternProperties: {} },
106+
want: `{
107+
[key: string]: unknown;
108+
}`,
109+
},
110+
],
111+
[
112+
"patternProperties > basic",
113+
{
114+
given: { type: "object", patternProperties: { "^a": { type: "string" } } },
115+
want: `{
116+
[key: string]: string;
117+
}`,
118+
},
119+
],
120+
[
121+
"patternProperties > enum",
122+
{
123+
given: { type: "object", patternProperties: { "^a": { type: "string", enum: ["a", "b", "c"] } } },
124+
want: `{
125+
[key: string]: "a" | "b" | "c";
126+
}`,
127+
},
128+
],
129+
[
130+
"patternProperties > multiple patterns",
131+
{
132+
given: { type: "object", patternProperties: { "^a": { type: "string" }, "^b": { type: "number" } } },
133+
want: `{
134+
[key: string]: string | number;
135+
}`,
136+
},
137+
],
138+
[
139+
"patternProperties > additional and patterns",
140+
{
141+
given: { type: "object", additionalProperties: { type: "number" }, patternProperties: { "^a": { type: "string" } } },
142+
want: `{
143+
[key: string]: number | string;
144+
}`,
145+
},
146+
],
102147
[
103148
"nullable",
104149
{

0 commit comments

Comments
 (0)