From 6236894f3f6c2c17fe1da70fed72dceefa18b4b1 Mon Sep 17 00:00:00 2001 From: koooge Date: Fri, 21 Apr 2023 00:26:00 +0200 Subject: [PATCH] test: Integration test Signed-off-by: koooge --- .github/workflows/ci.yaml | 8 ++++++++ test/.gitignore | 1 + test/fixture/tsconfig.node.json | 11 +++++++++++ test/fixture/tsconfig.node16.json | 11 +++++++++++ test/index.cjs | 8 ++++++++ test/index.d.ts | 1 + test/index.mjs | 8 ++++++++ test/index.ts | 8 ++++++++ test/package.json | 17 +++++++++++++++++ tsconfig.json | 2 +- 10 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 test/.gitignore create mode 100644 test/fixture/tsconfig.node.json create mode 100644 test/fixture/tsconfig.node16.json create mode 100644 test/index.cjs create mode 100644 test/index.d.ts create mode 100644 test/index.mjs create mode 100644 test/index.ts create mode 100644 test/package.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83ac8d4..5859bf7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,3 +20,11 @@ jobs: run: npm run build - name: Test + coverage run: npm run cover:ci + - name: Integration Test + run: | + cd test + npm i + npm run test:cjs + npm run test:mjs + npm run test:ts-node16 + npm run test:ts-esm-node16 diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..0dec61d --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +/package-lock.json diff --git a/test/fixture/tsconfig.node.json b/test/fixture/tsconfig.node.json new file mode 100644 index 0000000..2be3f32 --- /dev/null +++ b/test/fixture/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "target": "es2020", + "module": "commonjs", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/test/fixture/tsconfig.node16.json b/test/fixture/tsconfig.node16.json new file mode 100644 index 0000000..cfb4a2e --- /dev/null +++ b/test/fixture/tsconfig.node16.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "moduleResolution": "node16", + "target": "es2020", + "module": "commonjs", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/test/index.cjs b/test/index.cjs new file mode 100644 index 0000000..61e9af7 --- /dev/null +++ b/test/index.cjs @@ -0,0 +1,8 @@ +const assert = require('node:assert'); +const { oas31 } = require('openapi3-ts'); +const { OpenApiBuilder } = require('openapi3-ts/oas31'); + +const builder1 = new oas31.OpenApiBuilder(); +assert.ok(typeof builder1.rootDoc === 'object'); +const builder2 = new OpenApiBuilder(); +assert.ok(typeof builder2.rootDoc === 'object'); diff --git a/test/index.d.ts b/test/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/index.mjs b/test/index.mjs new file mode 100644 index 0000000..5a796c4 --- /dev/null +++ b/test/index.mjs @@ -0,0 +1,8 @@ +import assert from 'node:assert'; +import { oas31 } from 'openapi3-ts'; +import { OpenApiBuilder } from 'openapi3-ts/oas31'; + +const builder1 = new oas31.OpenApiBuilder(); +assert.ok(typeof builder1.rootDoc === 'object'); +const builder2 = new OpenApiBuilder(); +assert.ok(typeof builder2.rootDoc === 'object'); diff --git a/test/index.ts b/test/index.ts new file mode 100644 index 0000000..5a796c4 --- /dev/null +++ b/test/index.ts @@ -0,0 +1,8 @@ +import assert from 'node:assert'; +import { oas31 } from 'openapi3-ts'; +import { OpenApiBuilder } from 'openapi3-ts/oas31'; + +const builder1 = new oas31.OpenApiBuilder(); +assert.ok(typeof builder1.rootDoc === 'object'); +const builder2 = new OpenApiBuilder(); +assert.ok(typeof builder2.rootDoc === 'object'); diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..81d5eb8 --- /dev/null +++ b/test/package.json @@ -0,0 +1,17 @@ +{ + "name": "openapi3-ts-test", + "version": "1.0.0", + "main": "index.cjs", + "scripts": { + "test:cjs": "node index.cjs", + "test:mjs": "node index.mjs", + "test:ts": "ts-node --project fixture/tsconfig.node.json index.ts", + "test:ts-esm": "ts-node --esm --project fixture/tsconfig.node.json index.ts", + "test:ts-node16": "ts-node --project fixture/tsconfig.node16.json index.ts", + "test:ts-esm-node16": "ts-node --esm --project fixture/tsconfig.node16.json index.ts" + }, + "dependencies": { + "openapi3-ts": "file:..", + "ts-node": "^10.9.1" + } +} diff --git a/tsconfig.json b/tsconfig.json index 9e0c572..33dc8ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,5 @@ }, "buildOnSave": true, "compileOnSave": true, - "exclude": ["**/*.spec.ts", "bin", "dist", "vite.config.ts", "node_modules/**"] + "exclude": ["**/*.spec.ts", "bin", "dist", "test", "vite.config.ts", "node_modules/**"] }