mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00

Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Chromatic / Run Chromatic (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
98 lines
2.2 KiB
TypeScript
98 lines
2.2 KiB
TypeScript
import type { ApiRelationshipJSON } from '@/mastodon/api_types/relationships';
|
|
import type {
|
|
CustomEmojiData,
|
|
UnicodeEmojiData,
|
|
} from '@/mastodon/features/emoji/types';
|
|
import { createAccountFromServerJSON } from '@/mastodon/models/account';
|
|
import type { ApiAccountJSON } from 'mastodon/api_types/accounts';
|
|
|
|
type FactoryOptions<T> = {
|
|
id?: string;
|
|
} & Partial<T>;
|
|
|
|
type FactoryFunction<T> = (options?: FactoryOptions<T>) => T;
|
|
|
|
export const accountFactory: FactoryFunction<ApiAccountJSON> = ({
|
|
id,
|
|
...data
|
|
} = {}) => ({
|
|
id: id ?? '1',
|
|
acct: 'testuser',
|
|
avatar: '/avatars/original/missing.png',
|
|
avatar_static: '/avatars/original/missing.png',
|
|
username: 'testuser',
|
|
display_name: 'Test User',
|
|
bot: false,
|
|
created_at: '2023-01-01T00:00:00.000Z',
|
|
discoverable: true,
|
|
emojis: [],
|
|
fields: [],
|
|
followers_count: 0,
|
|
following_count: 0,
|
|
group: false,
|
|
header: '/header.png',
|
|
header_static: '/header_static.png',
|
|
indexable: true,
|
|
last_status_at: '2023-01-01',
|
|
locked: false,
|
|
mute_expires_at: null,
|
|
note: 'This is a test user account.',
|
|
statuses_count: 0,
|
|
suspended: false,
|
|
url: '/@testuser',
|
|
uri: '/users/testuser',
|
|
noindex: false,
|
|
roles: [],
|
|
hide_collections: false,
|
|
...data,
|
|
});
|
|
|
|
export const accountFactoryState = (
|
|
options: FactoryOptions<ApiAccountJSON> = {},
|
|
) => createAccountFromServerJSON(accountFactory(options));
|
|
|
|
export const relationshipsFactory: FactoryFunction<ApiRelationshipJSON> = ({
|
|
id,
|
|
...data
|
|
} = {}) => ({
|
|
id: id ?? '1',
|
|
following: false,
|
|
followed_by: false,
|
|
blocking: false,
|
|
blocked_by: false,
|
|
languages: null,
|
|
muting_notifications: false,
|
|
note: '',
|
|
requested_by: false,
|
|
muting: false,
|
|
requested: false,
|
|
domain_blocking: false,
|
|
endorsed: false,
|
|
notifying: false,
|
|
showing_reblogs: true,
|
|
...data,
|
|
});
|
|
|
|
export function unicodeEmojiFactory(
|
|
data: Partial<UnicodeEmojiData> = {},
|
|
): UnicodeEmojiData {
|
|
return {
|
|
hexcode: 'test',
|
|
label: 'Test',
|
|
unicode: '🧪',
|
|
...data,
|
|
};
|
|
}
|
|
|
|
export function customEmojiFactory(
|
|
data: Partial<CustomEmojiData> = {},
|
|
): CustomEmojiData {
|
|
return {
|
|
shortcode: 'custom',
|
|
static_url: 'emoji/custom/static',
|
|
url: 'emoji/custom',
|
|
visible_in_picker: true,
|
|
...data,
|
|
};
|
|
}
|