Skip to content

Commit

Permalink
Add more nullable tests (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
DangoDev committed May 5, 2020
1 parent e96f8f4 commit dbe7e0f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 47 deletions.
89 changes: 48 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"dependencies": {
"chalk": "^4.0.0",
"js-yaml": "^3.13.1",
"meow": "^6.1.0",
"meow": "^6.1.1",
"prettier": "^2.0.5"
},
"devDependencies": {
Expand All @@ -75,7 +75,7 @@
"@types/js-yaml": "^3.12.3",
"@types/prettier": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"@typescript-eslint/parser": "^2.31.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
Expand Down
35 changes: 31 additions & 4 deletions tests/v3/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ describe("types", () => {
},
string: { type: "string" },
string_ref: { $ref: "#/components/schemas/string" },
nullable: {
type: "string",
nullable: true,
},
},
},
};
Expand All @@ -53,6 +57,7 @@ describe("types", () => {
object: { string?: string };
string: string;
string_ref: components['schemas']['string'];
nullable: string | null;
}
}`)
);
Expand All @@ -72,6 +77,10 @@ describe("types", () => {
},
number: { type: "number" },
number_ref: { $ref: "#/components/schemas/number" },
nullable: {
type: "number",
nullable: true,
},
},
},
};
Expand All @@ -82,6 +91,7 @@ describe("types", () => {
object: { integer?: number; number?: number }
number: number;
number_ref: components['schemas']['number'];
nullable: number | null;
}
}`)
);
Expand All @@ -98,6 +108,7 @@ describe("types", () => {
},
boolean: { type: "boolean" },
boolean_ref: { $ref: "#/components/schemas/boolean" },
nullable: { type: "boolean", nullable: true },
},
},
};
Expand All @@ -108,6 +119,7 @@ describe("types", () => {
object: { boolean?: boolean };
boolean: boolean;
boolean_ref: components['schemas']['boolean'];
nullable: boolean | null;
}
}`)
);
Expand Down Expand Up @@ -141,6 +153,13 @@ describe("types", () => {
},
object_unknown: { type: "object" },
object_empty: {},
nullable: {
type: "object",
properties: {
string: { type: "string" },
},
nullable: true,
},
},
},
};
Expand All @@ -156,6 +175,7 @@ describe("types", () => {
object_ref: { number?: number };
object_unknown: { [key: string]: any };
object_empty: { [key: string]: any };
nullable: { string?: string } | null;
}
}`)
);
Expand All @@ -181,14 +201,20 @@ describe("types", () => {
},
type: "object",
},
inferred_array: {
items: { $ref: "#/components/schemas/array" },
},

string: { type: "string" },
array_ref: {
items: { $ref: "#/components/schemas/array" },
type: "array",
},
inferred_array: {
items: { $ref: "#/components/schemas/array" },
},
nullable: {
type: "array",
items: { type: "string" },
nullable: true,
},
},
},
};
Expand All @@ -203,9 +229,10 @@ describe("types", () => {
numbers?: number[];
refs?: components['schemas']['string'][];
};
inferred_array: components['schemas']['array'][];
string: string;
array_ref: components['schemas']['array'][];
inferred_array: components['schemas']['array'][];
nullable: string[] | null;
}
}`)
);
Expand Down

0 comments on commit dbe7e0f

Please sign in to comment.