@@ -4,9 +4,10 @@ import * as assert from 'assert';
44import * as path from 'path' ;
55import httpServer = require( 'http-server' ) ;
66import * as fs from 'fs-extra' ;
7- import { createManager } from '../src' ;
8- import { Manager } from '../src' ;
9- import { SwaggerDataSource } from '../src/compatible/scripts/swagger' ;
7+ import { createManager } from '../src/utils' ;
8+ import { Translator } from '../src/translate' ;
9+ import { Manager } from '../src/manage' ;
10+ import { SwaggerDataSource } from '../src/scripts/swagger' ;
1011
1112const getPath = fname => path . join ( __dirname , fname ) ;
1213const clearDir = dirName => {
@@ -35,7 +36,7 @@ describe('pont功能测试', () => {
3536
3637 server . listen ( { port : 9099 } , async ( ) => {
3738 console . log ( 'http server start successfull' ) ;
38- manager = ( await createManager ( 'config-multiple-origins.json' ) as Manager ) ;
39+ manager = await createManager ( 'config-multiple-origins.json' ) ;
3940 manager . diffs ;
4041 // 读取 api.d.ts 并转换为单行
4142 const codeBuffer = await fs . readFile ( getPath ( 'services/api1/api.d.ts' ) ) ;
@@ -90,6 +91,15 @@ describe('pont功能测试', () => {
9091 assert . ok ( ! apidts . includes ( wrongCode ) ) ;
9192 } ) ;
9293
94+ test ( 'api.d.ts should translate chinese of baseClass to english' , ( ) => {
95+ let dict : { [ key : string ] : string } = Translator . dict ;
96+ [ '通用请求参数token' , '输出参数vo' , '查询参数' , 'abc输出参数' , ' 中英文 混合 带 空格 Vo ' ] . forEach ( cnKey => {
97+ const enKey = dict [ cnKey ] ;
98+ assert . ok ( enKey ) ;
99+ assert . ok ( apidts . includes ( enKey ) ) ;
100+ } ) ;
101+ } ) ;
102+
93103 test ( 'api.d.ts should transform Map without template params to object' , ( ) => {
94104 let rightCode = oneline ( `
95105 export namespace getAllMsgForMap {
@@ -117,7 +127,7 @@ describe('pont功能测试', () => {
117127 const manager = await createManager ( 'config-single-usingMultipleOrigins.json' ) ;
118128 assert . ok ( exists ( 'services/api1/api.d.ts' ) ) ;
119129 assert . ok ( ! exists ( 'services/api2/api.d.ts' ) ) ;
120- manager ! . stopPolling ( ) ;
130+ manager . stopPolling ( ) ;
121131 } ) ;
122132
123133 it ( 'mods or base update should generate history file and report' , async ( ) => {
@@ -126,7 +136,7 @@ describe('pont功能测试', () => {
126136
127137 // 模拟后端接口变更
128138 try {
129- const swaggerObj : any = JSON . parse ( originSource ) as SwaggerDataSource ;
139+ const swaggerObj = JSON . parse ( originSource ) as SwaggerDataSource ;
130140
131141 // 模拟改变参数是否必传
132142 swaggerObj [ 'paths' ] [ '/api/core/asset/credit/query/pastCreditCardBillGather' ] [ 'post' ] [
0 commit comments