mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Updating test setup
This commit is contained in:
parent
5a8c2a4d36
commit
0ae6185400
@ -26,7 +26,7 @@ const config: Config.InitialOptions = {
|
||||
// '<rootDir>/test/e2e/v3.node.spec.ts',
|
||||
// '<rootDir>/test/e2e/v3.axios.spec.ts',
|
||||
// '<rootDir>/test/e2e/v3.babel.spec.ts',
|
||||
'<rootDir>/test/e2e/v3.angular.spec.ts',
|
||||
// '<rootDir>/test/e2e/v3.angular.spec.ts',
|
||||
// '<rootDir>/test/e2e/client.fetch.spec.ts',
|
||||
// '<rootDir>/test/e2e/client.xhr.spec.ts',
|
||||
// '<rootDir>/test/e2e/client.node.spec.ts',
|
||||
|
||||
15786
package-lock.json
generated
Normal file
15786
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -76,6 +76,7 @@
|
||||
"@rollup/plugin-commonjs": "21.0.1",
|
||||
"@rollup/plugin-node-resolve": "13.1.3",
|
||||
"@rollup/plugin-typescript": "8.3.0",
|
||||
"@types/cross-spawn": "6.0.2",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/glob": "7.2.0",
|
||||
"@types/jest": "27.4.0",
|
||||
@ -87,6 +88,7 @@
|
||||
"abort-controller": "^3.0.0",
|
||||
"axios": "^0.25.0",
|
||||
"codecov": "3.8.3",
|
||||
"cross-spawn": "7.0.3",
|
||||
"eslint": "8.7.0",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-prettier": "4.0.0",
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { CollectionFormatService } from './services/CollectionFormatService';
|
||||
import { ComplexService } from './services/ComplexService';
|
||||
import { DefaultService } from './services/DefaultService';
|
||||
import { DefaultsService } from './services/DefaultsService';
|
||||
import { DuplicateService } from './services/DuplicateService';
|
||||
import { ErrorService } from './services/ErrorService';
|
||||
import { FormDataService } from './services/FormDataService';
|
||||
import { HeaderService } from './services/HeaderService';
|
||||
import { MultipartService } from './services/MultipartService';
|
||||
import { MultipleTags1Service } from './services/MultipleTags1Service';
|
||||
import { MultipleTags2Service } from './services/MultipleTags2Service';
|
||||
import { MultipleTags3Service } from './services/MultipleTags3Service';
|
||||
import { NoContentService } from './services/NoContentService';
|
||||
import { ParametersService } from './services/ParametersService';
|
||||
import { RequestBodyService } from './services/RequestBodyService';
|
||||
import { ResponseService } from './services/ResponseService';
|
||||
import { SimpleService } from './services/SimpleService';
|
||||
import { TypesService } from './services/TypesService';
|
||||
import { UploadService } from './services/UploadService';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: `<div>Angular</div>`,
|
||||
})
|
||||
export class AppComponent {}
|
||||
|
||||
@NgModule({
|
||||
imports: [BrowserModule, HttpClientModule],
|
||||
providers: [
|
||||
CollectionFormatService,
|
||||
ComplexService,
|
||||
DefaultService,
|
||||
DefaultsService,
|
||||
DuplicateService,
|
||||
ErrorService,
|
||||
FormDataService,
|
||||
HeaderService,
|
||||
MultipartService,
|
||||
MultipleTags1Service,
|
||||
MultipleTags2Service,
|
||||
MultipleTags3Service,
|
||||
NoContentService,
|
||||
ParametersService,
|
||||
RequestBodyService,
|
||||
ResponseService,
|
||||
SimpleService,
|
||||
TypesService,
|
||||
UploadService,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
10
test/e2e/assets/index.html
Normal file
10
test/e2e/assets/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<script type="module" src="js/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,7 +1,9 @@
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import 'zone.js';
|
||||
|
||||
// import { HttpClientModule } from '@angular/common/http';
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
// import { BrowserModule } from '@angular/platform-browser';
|
||||
// import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { CollectionFormatService } from './services/CollectionFormatService';
|
||||
import { ComplexService } from './services/ComplexService';
|
||||
@ -21,12 +23,12 @@ import { TypesService } from './services/TypesService';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: `<div>Angular</div>`,
|
||||
template: `<div>Angular</div>`,
|
||||
})
|
||||
export class AppComponent {}
|
||||
|
||||
@NgModule({
|
||||
imports: [BrowserModule, HttpClientModule],
|
||||
// imports: [BrowserModule, HttpClientModule],
|
||||
providers: [
|
||||
CollectionFormatService,
|
||||
ComplexService,
|
||||
@ -44,9 +46,10 @@ export class AppComponent {}
|
||||
SimpleService,
|
||||
TypesService,
|
||||
],
|
||||
declarations: [AppComponent],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
// platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
|
||||
console.log('oke');
|
||||
3
test/e2e/assets/main.ts
Normal file
3
test/e2e/assets/main.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as api from './index';
|
||||
|
||||
(window as any).api = api;
|
||||
@ -1,3 +0,0 @@
|
||||
import('./index.js').then(module => {
|
||||
window.api = module;
|
||||
});
|
||||
@ -5,7 +5,7 @@ import server from './scripts/server';
|
||||
describe('v3.node', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('client/axios', 'v3', 'axios', false, false, 'AppClient');
|
||||
compileWithTypescript('client/axios');
|
||||
compileWithTypescript('client/axios', 'index.ts');
|
||||
await server.start('client/axios');
|
||||
}, 30000);
|
||||
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.babel', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('client/babel', 'v3', 'fetch', true, true, 'AppClient');
|
||||
await copy('script.js', 'client/babel/script.js');
|
||||
await copy('index.html', 'client/babel/index.html');
|
||||
await copy('main.ts', 'client/babel/main.ts');
|
||||
compileWithBabel('client/babel');
|
||||
await server.start('client/babel');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.fetch', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('client/fetch', 'v3', 'fetch', false, false, 'AppClient');
|
||||
await copy('script.js', 'client/fetch/script.js');
|
||||
await copy('index.html', 'client/fetch/index.html');
|
||||
await copy('main.ts', 'client/fetch/main.ts');
|
||||
compileWithTypescript('client/fetch');
|
||||
await server.start('client/fetch');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.xhr', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('client/xhr', 'v3', 'xhr', false, false, 'AppClient');
|
||||
await copy('script.js', 'client/xhr/script.js');
|
||||
await copy('index.html', 'client/xhr/index.html');
|
||||
await copy('main.ts', 'client/xhr/main.ts');
|
||||
compileWithTypescript('client/xhr');
|
||||
await server.start('client/xhr');
|
||||
await browser.start();
|
||||
|
||||
@ -29,7 +29,7 @@ export const compileWithTypescript = (dir: string) => {
|
||||
allowSyntheticDefaultImports: true,
|
||||
experimentalDecorators: true,
|
||||
},
|
||||
include: ['./index.ts', './main.ts'],
|
||||
include: ['**/*.ts'],
|
||||
};
|
||||
|
||||
// Compile files to JavaScript (ES6 modules)
|
||||
|
||||
33
test/e2e/scripts/createAngularProject.ts
Normal file
33
test/e2e/scripts/createAngularProject.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { spawn } from 'cross-spawn';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
|
||||
export const createAngularProject = async (dir: string) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const child = spawn('ng', [
|
||||
'new',
|
||||
'test',
|
||||
'--minimal true',
|
||||
'--style css',
|
||||
'--inline-style true',
|
||||
'--inline-template true',
|
||||
'--routing false',
|
||||
'--skip-install true',
|
||||
'--skip-tests true',
|
||||
'--commit false',
|
||||
'--force',
|
||||
], {
|
||||
cwd: resolvePath(dir)
|
||||
});
|
||||
|
||||
child.stdout.on('data', console.log);
|
||||
child.stderr.on('data', console.error);
|
||||
|
||||
child.on('exit', code => {
|
||||
if (code !== 0) {
|
||||
reject(code);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
import express, { Express } from 'express';
|
||||
import { Server } from 'http';
|
||||
import { EOL } from 'os';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
|
||||
let _app: Express;
|
||||
let _server: Server;
|
||||
@ -20,26 +20,9 @@ const start = async (dir: string) => {
|
||||
})
|
||||
);
|
||||
|
||||
// When we request the index then we can just return the script loader.
|
||||
// This file is copied from test/e2e/assets/script.js to the output directory
|
||||
// of the specific version and client.
|
||||
// Serve the index.html file
|
||||
_app.get('/', (req, res) => {
|
||||
res.send(
|
||||
[
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<meta charset="utf-8">',
|
||||
'<title>Test</title>',
|
||||
'</head>',
|
||||
'<body>',
|
||||
'<app-root></app-root>',
|
||||
'<script src="js/main.js"></script>',
|
||||
'<script src="js/script.js"></script>',
|
||||
'</body>',
|
||||
'</html>',
|
||||
].join(EOL)
|
||||
);
|
||||
res.sendFile(resolvePath(`./test/e2e/generated/${dir}/index.html`));
|
||||
});
|
||||
|
||||
// Register an 'echo' server for testing error codes. This will just grab the
|
||||
@ -67,7 +50,9 @@ const start = async (dir: string) => {
|
||||
});
|
||||
}, 100);
|
||||
});
|
||||
_server = _app.listen(3000, resolve);
|
||||
_server = _app.listen(3000, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -3,13 +3,15 @@ import { compileWithTypescript } from './scripts/compileWithTypescript';
|
||||
import { copy } from './scripts/copy';
|
||||
import { generate } from './scripts/generate';
|
||||
import server from './scripts/server';
|
||||
import {createAngularProject} from "./scripts/createAngularProject";
|
||||
|
||||
describe('v2.angular', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v2/angular', 'v2', 'angular');
|
||||
await copy('script.js', 'v2/angular/script.js');
|
||||
await copy('angular-openapi-v2.ts', 'v2/angular/main.ts');
|
||||
compileWithTypescript('v2/angular');
|
||||
// await copy('index.html', 'v2/angular/index.html');
|
||||
// await copy('main-angular.ts', 'v2/angular/main.ts');
|
||||
// compileWithTypescript('v2/angular');
|
||||
await createAngularProject('v2/angular/');
|
||||
await server.start('v2/angular');
|
||||
await browser.start();
|
||||
}, 30000);
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v2.babel', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v2/babel', 'v2', 'fetch', true, true);
|
||||
await copy('script.js', 'v2/babel/script.js');
|
||||
await copy('index.html', 'v2/babel/index.html');
|
||||
await copy('main.ts', 'v2/babel/main.ts');
|
||||
compileWithBabel('v2/babel');
|
||||
await server.start('v2/babel');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v2.fetch', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v2/fetch', 'v2', 'fetch');
|
||||
await copy('script.js', 'v2/fetch/script.js');
|
||||
await copy('index.html', 'v2/fetch/index.html');
|
||||
await copy('main.ts', 'v2/fetch/main.ts');
|
||||
compileWithTypescript('v2/fetch');
|
||||
await server.start('v2/fetch');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v2.xhr', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v2/xhr', 'v2', 'xhr');
|
||||
await copy('script.js', 'v2/xhr/script.js');
|
||||
await copy('index.html', 'v2/xhr/index.html');
|
||||
await copy('main.ts', 'v2/xhr/main.ts');
|
||||
compileWithTypescript('v2/xhr');
|
||||
await server.start('v2/xhr');
|
||||
await browser.start();
|
||||
|
||||
@ -7,8 +7,9 @@ import server from './scripts/server';
|
||||
describe('v3.angular', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v3/angular', 'v3', 'angular');
|
||||
await copy('index.html', 'v3/angular/index.html');
|
||||
await copy('script.js', 'v3/angular/script.js');
|
||||
await copy('angular-openapi-v3.ts', 'v3/angular/main.ts');
|
||||
await copy('main-angular.ts', 'v3/angular/main.ts');
|
||||
compileWithTypescript('v3/angular');
|
||||
await server.start('v3/angular');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.babel', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v3/babel', 'v3', 'fetch', true, true);
|
||||
await copy('script.js', 'v3/babel/script.js');
|
||||
await copy('index.html', 'v3/babel/index.html');
|
||||
await copy('main.ts', 'v3/babel/main.ts');
|
||||
compileWithBabel('v3/babel');
|
||||
await server.start('v3/babel');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.fetch', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v3/fetch', 'v3', 'fetch');
|
||||
await copy('script.js', 'v3/fetch/script.js');
|
||||
await copy('index.html', 'v3/fetch/index.html');
|
||||
await copy('main.ts', 'v3/fetch/main.ts');
|
||||
compileWithTypescript('v3/fetch');
|
||||
await server.start('v3/fetch');
|
||||
await browser.start();
|
||||
|
||||
@ -7,7 +7,8 @@ import server from './scripts/server';
|
||||
describe('v3.xhr', () => {
|
||||
beforeAll(async () => {
|
||||
await generate('v3/xhr', 'v3', 'xhr');
|
||||
await copy('script.js', 'v3/xhr/script.js');
|
||||
await copy('index.html', 'v3/xhr/index.html');
|
||||
await copy('main.ts', 'v3/xhr/main.ts');
|
||||
compileWithTypescript('v3/xhr');
|
||||
await server.start('v3/xhr');
|
||||
await browser.start();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user