Skip to content

Commit 299e260

Browse files
committed
test: 修复测试问题
1 parent 0de988f commit 299e260

4 files changed

Lines changed: 58 additions & 9 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name: "CodeQL"
77

88
on:
99
push:
10-
branches: [master]
10+
branches: [main]
1111
pull_request:
1212
# The branches below must be a subset of the branches above
13-
branches: [master]
13+
branches: [main]
1414
schedule:
1515
- cron: '0 17 * * 0'
1616

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x, 22.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'pnpm'
26+
27+
- name: Install pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: latest
31+
32+
- name: Install dependencies
33+
run: pnpm install
34+
35+
- name: Run code format check
36+
run: pnpm run check
37+
38+
- name: Build project
39+
run: pnpm run build
40+
41+
- name: Run tests
42+
run: pnpm run test:lib
43+
44+
- name: Run tests with coverage
45+
run: pnpm run test:cov
46+
if: matrix.node-version == '20.x'
47+
48+
- name: Upload coverage to Coveralls
49+
uses: coverallsapp/github-action@v2
50+
if: matrix.node-version == '20.x'
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
path-to-lcov: ./coverage/lcov.info

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[![NPM version][npm-image]][npm-url]
2-
[![build status][travis-image]][travis-url]
32
[![Test coverage][coveralls-image]][coveralls-url]
4-
[![David deps][david-image]][david-url]
53
[![node version][node-image]][node-url]
64
[![npm download][download-image]][download-url]
75
[![npm license][license-image]][download-url]
@@ -10,10 +8,8 @@
108
[npm-image]: https://img.shields.io/npm/v/erest.svg?style=flat-square
119
[npm-url]: https://npmjs.org/package/erest
1210
[travis-image]: https://img.shields.io/travis/yourtion/node-erest.svg?style=flat-square
13-
[travis-url]: https://travis-ci.org/yourtion/node-erest
1411
[coveralls-image]: https://img.shields.io/coveralls/yourtion/node-erest.svg?style=flat-square
1512
[coveralls-url]: https://coveralls.io/r/yourtion/node-erest?branch=master
16-
[david-image]: https://img.shields.io/david/yourtion/node-erest.svg?style=flat-square
1713
[david-url]: https://david-dm.org/yourtion/node-erest
1814
[node-image]: https://img.shields.io/badge/node.js-%3E=_10-green.svg?style=flat-square
1915
[node-url]: http://nodejs.org/download/

src/lib/plugin/generate_markdown/apis.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { SchemaType } from "@tuzhanai/schema-manager";
21
import type { APIOption, IExample, TYPE_RESPONSE } from "../../api";
32
import type { IDocData } from "../../extend/docs";
4-
import type { ISchemaType } from "../../params";
3+
import type { ISchemaType, SchemaType } from "../../params";
4+
import { isZodSchema } from "../../params";
55
import { jsonStringify } from "../../utils";
66
import { fieldString, itemTF, itemTFEmoji, stringOrEmpty, tableHeader } from "./utils";
77

@@ -68,7 +68,7 @@ export default function apiDocs(data: IDocData) {
6868
return `[${response}](/schema#${response.replace("[]", "").toLocaleLowerCase()})`;
6969
}
7070
// FIXME: 处理更多返回类型
71-
if (response instanceof SchemaType || typeof response.type === "string") return;
71+
if (isZodSchema(response) || typeof response.type === "string") return;
7272
const paramsList: string[] = [];
7373
paramsList.push(tableHeader(["参数名", "类型", "必填", "说明"]));
7474
// 参数输出

0 commit comments

Comments
 (0)