3980e9651e
Reviewed-on: #357 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
143 行
3.8 KiB
TypeScript
143 行
3.8 KiB
TypeScript
import type { Material,
|
|
Post,
|
|
Tag,
|
|
Theatre,
|
|
TheatreComment,
|
|
TheatreInfo,
|
|
TheatrePostSelectionWeights,
|
|
TheatreProgramme,
|
|
User,
|
|
WikiPage } from '@/types'
|
|
|
|
export const buildTag = (overrides: Partial<Tag> = {}): Tag => ({
|
|
id: 1,
|
|
name: 'テストタグ',
|
|
category: 'general',
|
|
aliases: [],
|
|
parents: [],
|
|
postCount: 12,
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
updatedAt: '2026-01-03T03:04:05.000Z',
|
|
hasWiki: false,
|
|
materialId: null,
|
|
hasDeerjikists: false,
|
|
matchedAlias: null,
|
|
...overrides,
|
|
})
|
|
|
|
export const buildPost = (overrides: Partial<Post> = {}): Post => ({
|
|
id: 1,
|
|
versionNo: 1,
|
|
url: 'https://example.com/post/1',
|
|
title: 'テスト投稿',
|
|
thumbnail: 'https://example.com/thumb.jpg',
|
|
thumbnailBase: null,
|
|
tags: [buildTag ()],
|
|
parentPosts: [],
|
|
childPosts: [],
|
|
siblingPosts: {},
|
|
viewed: false,
|
|
related: [],
|
|
originalCreatedFrom: null,
|
|
originalCreatedBefore: null,
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
updatedAt: '2026-01-03T03:04:05.000Z',
|
|
uploadedUser: { id: 1, name: 'tester' },
|
|
...overrides,
|
|
})
|
|
|
|
export const buildUser = (overrides: Partial<User> = {}): User => ({
|
|
id: 1,
|
|
name: 'tester',
|
|
inheritanceCode: 'inherit-code',
|
|
role: 'member',
|
|
...overrides,
|
|
})
|
|
|
|
export const buildWikiPage = (overrides: Partial<WikiPage> = {}): WikiPage => ({
|
|
id: 1,
|
|
title: 'テストWiki',
|
|
createdUserId: 1,
|
|
updatedUserId: 1,
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
updatedAt: '2026-01-03T03:04:05.000Z',
|
|
body: '# 本文',
|
|
revisionId: 10,
|
|
pred: null,
|
|
succ: null,
|
|
...overrides,
|
|
})
|
|
|
|
export const buildMaterial = (overrides: Partial<Material> = {}): Material => ({
|
|
id: 1,
|
|
tag: buildTag (),
|
|
file: null,
|
|
url: null,
|
|
wikiPageBody: null,
|
|
contentType: null,
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
createdByUser: { id: 1, name: 'creator' },
|
|
updatedAt: '2026-01-03T03:04:05.000Z',
|
|
updatedByUser: { id: 2, name: 'updater' },
|
|
...overrides,
|
|
})
|
|
|
|
export const buildTheatre = (overrides: Partial<Theatre> = {}): Theatre => ({
|
|
id: 1,
|
|
name: 'テスト劇場',
|
|
opensAt: '2026-01-02T03:04:05.000Z',
|
|
closesAt: null,
|
|
createdByUser: { id: 1, name: 'creator' },
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
updatedAt: '2026-01-03T03:04:05.000Z',
|
|
...overrides,
|
|
})
|
|
|
|
export const buildTheatreInfo = (
|
|
overrides: Partial<TheatreInfo> = {},
|
|
): TheatreInfo => ({
|
|
hostFlg: false,
|
|
postId: null,
|
|
postStartedAt: null,
|
|
postElapsedMs: null,
|
|
watchingUsers: [],
|
|
skipVote: {
|
|
votesCount: 0,
|
|
requiredCount: 1,
|
|
watchingUsersCount: 0,
|
|
voted: false,
|
|
},
|
|
...overrides,
|
|
})
|
|
|
|
export const buildTheatreComment = (
|
|
overrides: Partial<TheatreComment> = {},
|
|
): TheatreComment => ({
|
|
theatreId: 1,
|
|
no: 1,
|
|
deleted: false,
|
|
user: { id: 1, name: 'tester' },
|
|
content: 'テストコメント',
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
...overrides,
|
|
} as TheatreComment)
|
|
|
|
export const buildTheatreProgramme = (
|
|
overrides: Partial<TheatreProgramme> = {},
|
|
): TheatreProgramme => ({
|
|
theatreId: 1,
|
|
position: 1,
|
|
post: buildPost (),
|
|
createdAt: '2026-01-02T03:04:05.000Z',
|
|
...overrides,
|
|
})
|
|
|
|
export const buildTheatrePostSelectionWeights = (
|
|
overrides: Partial<TheatrePostSelectionWeights> = {},
|
|
): TheatrePostSelectionWeights => ({
|
|
tagPenalties: [],
|
|
lightestPosts: [],
|
|
heaviestPosts: [],
|
|
...overrides,
|
|
})
|