|
- import type { Material, Post, TagWithSections, User, WikiPage } from '@/types'
-
- export const buildTag = (overrides: Partial<TagWithSections> = {}): TagWithSections => ({
- 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,
- sections: [],
- children: [],
- ...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,
- })
|