1
This commit is contained in:
38
src/components/rpg-entry/rpgEntryWorldPresentation.test.ts
Normal file
38
src/components/rpg-entry/rpgEntryWorldPresentation.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { expect, test } from 'vitest';
|
||||
|
||||
import {
|
||||
formatPlatformWorkDisplayName,
|
||||
formatPlatformWorkDisplayTags,
|
||||
formatPlatformWorldTime,
|
||||
} from './rpgEntryWorldPresentation';
|
||||
|
||||
test('formatPlatformWorldTime formats backend seconds timestamp text as date', () => {
|
||||
expect(formatPlatformWorldTime('1777110165.990127Z')).toBe('2026-04-25');
|
||||
});
|
||||
|
||||
test('formatPlatformWorldTime keeps full year for iso date strings', () => {
|
||||
expect(formatPlatformWorldTime('2026-04-25T12:00:00.000Z')).toBe(
|
||||
'2026-04-25',
|
||||
);
|
||||
});
|
||||
|
||||
test('formatPlatformWorldTime uses utc calendar date for zulu time', () => {
|
||||
expect(formatPlatformWorldTime('2026-04-25T00:30:00.000Z')).toBe(
|
||||
'2026-04-25',
|
||||
);
|
||||
});
|
||||
|
||||
test('formatPlatformWorldTime keeps fallback text for invalid values', () => {
|
||||
expect(formatPlatformWorldTime(null)).toBe('未发布');
|
||||
expect(formatPlatformWorldTime('not-a-date')).toBe('not-a-date');
|
||||
});
|
||||
|
||||
test('platform work display text limits names and tags by character count', () => {
|
||||
expect(formatPlatformWorkDisplayName('热门高分拼图超长标题')).toBe(
|
||||
'热门高分拼图超长',
|
||||
);
|
||||
expect(formatPlatformWorkDisplayTags(['超长机关标签', '星桥', '超长机关标签'])).toEqual([
|
||||
'超长机关',
|
||||
'星桥',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user