|
1 | | -import fs from "node:fs"; |
| 1 | +import { URL } from "node:url"; |
2 | 2 | import openapiTS from "../dist/index.js"; |
3 | 3 | import type { OpenAPI3 } from "../src/types.js"; |
| 4 | +import { readFile } from "./helpers.js"; |
4 | 5 |
|
5 | 6 | const BOILERPLATE = `/** |
6 | 7 | * This file was auto-generated by openapi-typescript. |
@@ -784,7 +785,7 @@ export type operations = Record<string, never>; |
784 | 785 | }, |
785 | 786 | }, |
786 | 787 | }, |
787 | | - { exportType: false } |
| 788 | + { exportType: false }, |
788 | 789 | ); |
789 | 790 | expect(generated).toBe(`${BOILERPLATE} |
790 | 791 | export type paths = Record<string, never>; |
@@ -826,7 +827,7 @@ export type operations = Record<string, never>; |
826 | 827 | }, |
827 | 828 | }, |
828 | 829 | }, |
829 | | - { exportType: true } |
| 830 | + { exportType: true }, |
830 | 831 | ); |
831 | 832 | expect(generated).toBe(`${BOILERPLATE} |
832 | 833 | export type paths = Record<string, never>; |
@@ -1091,7 +1092,7 @@ export type operations = Record<string, never>; |
1091 | 1092 | }, |
1092 | 1093 | }, |
1093 | 1094 | }, |
1094 | | - { exportType: false } |
| 1095 | + { exportType: false }, |
1095 | 1096 | ); |
1096 | 1097 | expect(generated).toBe(`${BOILERPLATE}${ONE_OF_TYPE_HELPERS} |
1097 | 1098 | export type paths = Record<string, never>; |
@@ -1144,7 +1145,7 @@ export type operations = Record<string, never>; |
1144 | 1145 | }, |
1145 | 1146 | }, |
1146 | 1147 | }, |
1147 | | - { exportType: false } |
| 1148 | + { exportType: false }, |
1148 | 1149 | ); |
1149 | 1150 | expect(generated).toBe(`${BOILERPLATE}${WITH_REQUIRED_TYPE_HELPERS} |
1150 | 1151 | export type paths = Record<string, never>; |
@@ -1206,32 +1207,37 @@ export type operations = Record<string, never>; |
1206 | 1207 | describe("GitHub", () => { |
1207 | 1208 | test("default options", async () => { |
1208 | 1209 | const generated = await openapiTS(new URL("./github-api.yaml", EXAMPLES_DIR)); |
1209 | | - expect(generated).toBe(fs.readFileSync(new URL("./github-api.ts", EXAMPLES_DIR), "utf8")); |
| 1210 | + expect(generated).toBe(readFile(new URL("./github-api.ts", EXAMPLES_DIR))); |
1210 | 1211 | }, 30000); |
1211 | 1212 | }); |
1212 | 1213 | describe("GitHub (next)", () => { |
1213 | 1214 | test("default options", async () => { |
1214 | 1215 | const generated = await openapiTS(new URL("./github-api-next.yaml", EXAMPLES_DIR)); |
1215 | | - expect(generated).toBe(fs.readFileSync(new URL("./github-api-next.ts", EXAMPLES_DIR), "utf8")); |
| 1216 | + expect(generated).toBe(readFile(new URL("./github-api-next.ts", EXAMPLES_DIR))); |
1216 | 1217 | }, 30000); |
1217 | 1218 | }); |
1218 | 1219 | describe("Octokit GHES 3.6 Diff to API", () => { |
1219 | 1220 | test("default options", async () => { |
1220 | 1221 | const generated = await openapiTS(new URL("./octokit-ghes-3.6-diff-to-api.json", EXAMPLES_DIR)); |
1221 | | - expect(generated).toBe(fs.readFileSync(new URL("./octokit-ghes-3.6-diff-to-api.ts", EXAMPLES_DIR), "utf8")); |
| 1222 | + expect(generated).toBe(readFile(new URL("./octokit-ghes-3.6-diff-to-api.ts", EXAMPLES_DIR))); |
1222 | 1223 | }, 30000); |
1223 | 1224 | }); |
1224 | 1225 | describe("Stripe", () => { |
1225 | 1226 | test("default options", async () => { |
1226 | 1227 | const generated = await openapiTS(new URL("./stripe-api.yaml", EXAMPLES_DIR)); |
1227 | | - expect(generated).toBe(fs.readFileSync(new URL("./stripe-api.ts", EXAMPLES_DIR), "utf8")); |
| 1228 | + expect(generated).toBe(readFile(new URL("./stripe-api.ts", EXAMPLES_DIR))); |
1228 | 1229 | }, 30000); |
1229 | 1230 | }); |
1230 | 1231 | describe("DigitalOcean", () => { |
1231 | | - test("default options", async () => { |
1232 | | - const generated = await openapiTS(new URL("./digital-ocean-api/DigitalOcean-public.v2.yaml", EXAMPLES_DIR)); |
1233 | | - expect(generated).toBe(fs.readFileSync(new URL("./digital-ocean-api.ts", EXAMPLES_DIR), "utf8")); |
1234 | | - }, 60000); |
| 1232 | + // this test runs too slowly on macos / windows in GitHub Actions (not not natively) |
| 1233 | + test.skipIf(process.env.CI_ENV === "macos" || process.env.CI_ENV === "windows")( |
| 1234 | + "default options", |
| 1235 | + async () => { |
| 1236 | + const generated = await openapiTS(new URL("./digital-ocean-api/DigitalOcean-public.v2.yaml", EXAMPLES_DIR)); |
| 1237 | + expect(generated).toBe(readFile(new URL("./digital-ocean-api.ts", EXAMPLES_DIR))); |
| 1238 | + }, |
| 1239 | + 60000, |
| 1240 | + ); |
1235 | 1241 | }); |
1236 | 1242 | }); |
1237 | 1243 | }); |
0 commit comments