81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { AchievementFormatter } from './AchievementFormatter';
|
|
|
|
describe('AchievementFormatter', () => {
|
|
describe('getRarityVariant', () => {
|
|
it('should format common rarity correctly', () => {
|
|
const result = AchievementFormatter.getRarityVariant('common');
|
|
expect(result).toEqual({
|
|
text: 'low',
|
|
surface: 'rarity-common',
|
|
iconIntent: 'low',
|
|
});
|
|
});
|
|
|
|
it('should format rare rarity correctly', () => {
|
|
const result = AchievementFormatter.getRarityVariant('rare');
|
|
expect(result).toEqual({
|
|
text: 'primary',
|
|
surface: 'rarity-rare',
|
|
iconIntent: 'primary',
|
|
});
|
|
});
|
|
|
|
it('should format epic rarity correctly', () => {
|
|
const result = AchievementFormatter.getRarityVariant('epic');
|
|
expect(result).toEqual({
|
|
text: 'primary',
|
|
surface: 'rarity-epic',
|
|
iconIntent: 'primary',
|
|
});
|
|
});
|
|
|
|
it('should format legendary rarity correctly', () => {
|
|
const result = AchievementFormatter.getRarityVariant('legendary');
|
|
expect(result).toEqual({
|
|
text: 'warning',
|
|
surface: 'rarity-legendary',
|
|
iconIntent: 'warning',
|
|
});
|
|
});
|
|
|
|
it('should handle case-insensitive rarity', () => {
|
|
const result = AchievementFormatter.getRarityVariant('COMMON');
|
|
expect(result).toEqual({
|
|
text: 'low',
|
|
surface: 'rarity-common',
|
|
iconIntent: 'low',
|
|
});
|
|
});
|
|
|
|
it('should default to common for unknown rarity', () => {
|
|
const result = AchievementFormatter.getRarityVariant('unknown');
|
|
expect(result).toEqual({
|
|
text: 'low',
|
|
surface: 'rarity-common',
|
|
iconIntent: 'low',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('formatDate', () => {
|
|
it('should format date correctly', () => {
|
|
const date = new Date('2026-01-15');
|
|
const result = AchievementFormatter.formatDate(date);
|
|
expect(result).toBe('Jan 15, 2026');
|
|
});
|
|
|
|
it('should format date with different months', () => {
|
|
const date = new Date('2026-12-25');
|
|
const result = AchievementFormatter.formatDate(date);
|
|
expect(result).toBe('Dec 25, 2026');
|
|
});
|
|
|
|
it('should handle single digit days', () => {
|
|
const date = new Date('2026-01-05');
|
|
const result = AchievementFormatter.formatDate(date);
|
|
expect(result).toBe('Jan 5, 2026');
|
|
});
|
|
});
|
|
});
|