Skip to content

Commit

Permalink
refactor: merge test node_modules into one
Browse files Browse the repository at this point in the history
  • Loading branch information
anshchaturvedi committed May 17, 2024
1 parent 5d03a0d commit 7ffa62a
Show file tree
Hide file tree
Showing 68 changed files with 31 additions and 109 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coverage/
dist/
flake.lock
tests/programs/*
2 changes: 1 addition & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions packages/openapi-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"io-ts": "2.1.3",
"io-ts-types": "0.5.19",
"openapi-types": "12.1.3",
"prettier": "^3.2.5",
"resolve": "1.22.8"
},
"devDependencies": {
Expand All @@ -38,8 +39,8 @@
"typescript": "^4.7.4"
},
"optionalDependencies": {
"@swc/core-linux-x64-gnu": "1.5.5",
"@swc/core-darwin-arm64": "1.5.5"
"@swc/core-darwin-arm64": "1.5.5",
"@swc/core-linux-x64-gnu": "1.5.5"
},
"publishConfig": {
"access": "public"
Expand Down
62 changes: 19 additions & 43 deletions packages/openapi-generator/test/externalModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ async function testCase(
test(description, async () => {
const project = new Project({}, KNOWN_IMPORTS);
const entryPointPath = p.resolve(entryPoint);
const result = await project.parseEntryPoint(entryPointPath);

if (E.isLeft(result)) {
}
await project.parseEntryPoint(entryPointPath);

for (const path of Object.keys(expected)) {
const resolvedPath = p.resolve(path);
Expand Down Expand Up @@ -119,101 +116,80 @@ const RANDOM_Object = (testNum: number): Schema => ({

testCase(
'type from correctly formatted external library with export declaration',
'test/projects/export-declaration/index.ts',
'test/sample-types/exportDeclaration.ts',
{
'test/projects/export-declaration/index.ts': {
'test/sample-types/exportDeclaration.ts': {
FOO: FOO_Object(1),
RANDOM: RANDOM_Object(1),
},
'test/projects/export-declaration/node_modules/@bitgo/foobar1/src/index.ts': {
'test/sample-types/node_modules/@bitgo/foobar1/src/index.ts': {
Foobar: FoobarObject,
},
'test/projects/export-declaration/node_modules/@bitgo/random-types1/src/index.ts': {
'test/sample-types/node_modules/@bitgo/random-types1/src/index.ts': {
RandomType: RandomTypeObject,
},
},
);

testCase(
'type from correctly formatted external library with export star declaration',
'test/projects/export-star/index.ts',
'test/sample-types/exportStar.ts',
{
'test/projects/export-star/index.ts': {
'test/sample-types/exportStar.ts': {
FOO: FOO_Object(2),
RANDOM: RANDOM_Object(2),
},
'test/projects/export-star/node_modules/@bitgo/foobar2/src/foobar.ts': {
'test/sample-types/node_modules/@bitgo/foobar2/src/foobar.ts': {
Foobar: FoobarObject,
},
'test/projects/export-star/node_modules/@bitgo/random-types2/src/randomType.ts': {
'test/sample-types/node_modules/@bitgo/random-types2/src/randomType.ts': {
RandomType: RandomTypeObject,
},
},
);

testCase(
'type from correctly formatted external library with export star declaration and import star declaration',
'test/projects/import-star/index.ts',
'test/sample-types/importStar.ts',
{
'test/projects/import-star/index.ts': {
'test/sample-types/importStar.ts': {
FOO: FOO_Object(4),
RANDOM: RANDOM_Object(4),
},
'test/projects/import-star/node_modules/@bitgo/foobar4/src/foobar.ts': {
'test/sample-types/node_modules/@bitgo/foobar4/src/foobar.ts': {
Foobar: FoobarObject,
},
'test/projects/import-star/node_modules/@bitgo/random-types4/src/randomType.ts': {
'test/sample-types/node_modules/@bitgo/random-types4/src/randomType.ts': {
RandomType: RandomTypeObject,
},
},
);

testCase(
'type from external library with syntax errors',
'test/projects/syntax-error/index.ts',
'test/sample-types/syntaxError.ts',
{
'test/projects/syntax-error/index.ts': {
'test/sample-types/syntaxError.ts': {
FOO: FOO_Object(5),
},
'test/projects/syntax-error/node_modules/@bitgo/foobar5/src/foobar.ts': {},
'test/sample-types/node_modules/@bitgo/foobar5/src/foobar.ts': {},
},
{
'test/projects/syntax-error/node_modules/@bitgo/foobar5/src/foobar.ts': [
'test/sample-types/node_modules/@bitgo/foobar5/src/foobar.ts': [
'Unknown identifier ttype',
],
},
);

test('type from external library with import path error', async () => {
const entryPoint = 'test/projects/import-path-error/index.ts';
const entryPoint = 'test/sample-types/importPathError.ts';
const project = new Project({}, KNOWN_IMPORTS);
const entryPointPath = p.resolve(entryPoint);
const result = await project.parseEntryPoint(entryPointPath);

const errorRegex =
/Could not resolve .* from .*\/api-ts\/packages\/openapi-generator\/test\/projects\/import-path-error\/node_modules\/@bitgo\/foobar3\/src/;
/Could not resolve io-tsg from .*\/test\/sample-types\/node_modules\/@bitgo\/foobar3\/src/;

assert(E.isLeft(result));
assert(errorRegex.test(result.left));
});

// testCase(
// 'type from external library with syntax errors',
// 'test/projects/bad-external-library/index.ts',
// {
// 'test/projects/bad-external-library/index.ts': {
// FOO: {
// type: 'object',
// properties: {
// foobar: {
// location: 'foobar',
// name: 'Foobar',
// type: 'ref',
// },
// },
// required: ['foobar'],
// },
// },
// },
// {},
// );

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/openapi-generator/test/projects/export-star/package.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/openapi-generator/test/projects/import-star/package.json

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/openapi-generator/test/projects/syntax-error/package.json

This file was deleted.

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

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

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

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

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

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

2 changes: 1 addition & 1 deletion packages/openapi-generator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts", "test/**/*.json", "test/**/*.ts"],
"exclude": ["test/projects/**/*"],
// "exclude": ["test/sample-types/**/*"],
"compilerOptions": {
"outDir": "dist"
},
Expand Down

0 comments on commit 7ffa62a

Please sign in to comment.