fix: test case

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2023-06-17 09:38:52 +08:00
parent 06e21ecdf1
commit fbcf2cc53f
4 changed files with 27 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import { SnippetController } from '~/modules/snippet/snippet.controller'
import { SnippetModel, SnippetType } from '~/modules/snippet/snippet.model'
import { SnippetService } from '~/modules/snippet/snippet.service'
import { DatabaseService } from '~/processors/database/database.service'
import { EventManagerService } from '~/processors/helper/helper.event.service'
describe('test /snippets', () => {
let app: NestFastifyApplication
@@ -17,6 +18,12 @@ describe('test /snippets', () => {
providers: [
SnippetService,
{ provide: DatabaseService, useValue: {} },
{
provide: EventManagerService,
useValue: {
async emit() {},
},
},
{
provide: ServerlessService,

View File

@@ -8,9 +8,11 @@ import { ServerlessService } from '~/modules/serverless/serverless.service'
import { SnippetModel, SnippetType } from '~/modules/snippet/snippet.model'
import { SnippetService } from '~/modules/snippet/snippet.service'
import { DatabaseService } from '~/processors/database/database.service'
import { EventManagerService } from '~/processors/helper/helper.event.service'
import { CacheService } from '~/processors/redis/cache.service'
import { getModelToken } from '~/transformers/model.transformer'
const mockedEventManageService = { async emit() {} }
describe('test Snippet Service', () => {
let service: SnippetService
@@ -22,6 +24,7 @@ describe('test Snippet Service', () => {
{ provide: DatabaseService, useValue: {} },
{ provide: CacheService, useValue: redis.CacheService },
{ provide: ServerlessService, useValue: {} },
{ provide: EventManagerService, useValue: mockedEventManageService },
{
provide: getModelToken(SnippetModel.name),

View File

@@ -3,7 +3,7 @@ import type { IController } from '~/interfaces/controller'
import type { SortOrder } from '~/interfaces/options'
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
import type {
AggregateRoot,
AggregateRootWithTheme,
AggregateStat,
AggregateTop,
TimelineData,
@@ -36,8 +36,14 @@ export class AggregateController<ResponseWrapper> implements IController {
/**
* 获取聚合数据
*/
getAggregateData(): RequestProxyResult<AggregateRoot, ResponseWrapper> {
return this.proxy.get<AggregateRoot>()
getAggregateData<Theme>(
theme?: string,
): RequestProxyResult<AggregateRootWithTheme<Theme>, ResponseWrapper> {
return this.proxy.get<AggregateRootWithTheme<Theme>>({
params: {
theme,
},
})
}
/**

View File

@@ -12,6 +12,14 @@ export interface AggregateRoot {
url: Url
categories: CategoryModel[]
pageMeta: Pick<PageModel, 'title' | 'id' | 'slug' | 'order'>[] | null
/**
* @available 4.2.2
*/
latestNoteId: { id: string; nid: number }
}
export interface AggregateRootWithTheme<Theme = unknown> extends AggregateRoot {
theme?: Theme
}
export interface Url {