Skip to content

Commit f1401f0

Browse files
jbl428imdudu1
andcommitted
fix: add coverage script
Co-authored-by: imdudu1 <[email protected]>
1 parent e88f172 commit f1401f0

File tree

7 files changed

+13
-18
lines changed

7 files changed

+13
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# nest-http-interface
1+
# nest-http-interface

global.vitest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import "reflect-metadata";
1+
import 'reflect-metadata';

lib/decorators/http-exchange.decorator.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import { HTTP_EXCHANGE_METADATA } from './constants';
22
import { HttpRequestBuilder } from '../builders/http-request.builder';
3-
import { type HttpMethod } from '../types/http-method';
3+
import { type HttpMethod } from '../types';
44

55
type AsyncFunction = (...args: any[]) => Promise<unknown>;
66

7-
export function HttpExchange(method: HttpMethod, url: string) {
8-
return function <P extends string>(
9-
target: Record<P, AsyncFunction>,
10-
propertyKey: P,
11-
) {
7+
export const HttpExchange =
8+
(method: HttpMethod, url: string) =>
9+
<P extends string>(target: Record<P, AsyncFunction>, propertyKey: P) => {
1210
Reflect.defineMetadata(
1311
HTTP_EXCHANGE_METADATA,
1412
new HttpRequestBuilder(target, propertyKey, method, url),
1513
target,
1614
propertyKey,
1715
);
1816
};
19-
}
2017

2118
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2219
export const GetExchange = (url = '') => HttpExchange('GET', url);

lib/http-interface.module.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ describe('HttpInterfaceModule', () => {
3131

3232
// then
3333
expect(response).toBe('{"data":"ok"}');
34+
await app.close();
3435
});
3536
});

lib/supports/node-fetch.injector.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ export class NodeFetchInjector implements OnModuleInit {
2727
wrapper.metatype.prototype,
2828
);
2929

30-
if (baseUrl == null) {
31-
return;
32-
}
33-
34-
this.wrapMethods(wrapper, baseUrl);
30+
this.wrapMethods(wrapper, baseUrl ?? '');
3531
});
3632
}
3733

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"build": "tsc --build --verbose tsconfig.build.json",
2525
"clean": "tsc --build --clean tsconfig.build.json",
2626
"test": "vitest run",
27+
"coverage": "vitest run --coverage",
2728
"prepare": "husky install"
2829
},
2930
"devDependencies": {

vitest.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { defineConfig } from "vitest/config";
1+
import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
5-
setupFiles: "./global.vitest.ts",
5+
setupFiles: './global.vitest.ts',
66
coverage: {
7-
provider: "c8",
8-
reporter: "lcov",
7+
provider: 'c8',
8+
reporter: 'lcov',
99
},
1010
},
1111
});

0 commit comments

Comments
 (0)