101 lines
3.3 KiB
TypeScript
101 lines
3.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { MedalFormatter } from './MedalFormatter';
|
|
|
|
describe('MedalFormatter', () => {
|
|
describe('getVariant', () => {
|
|
it('should return "warning" for 1st place', () => {
|
|
expect(MedalFormatter.getVariant(1)).toBe('warning');
|
|
});
|
|
|
|
it('should return "high" for 2nd place', () => {
|
|
expect(MedalFormatter.getVariant(2)).toBe('high');
|
|
});
|
|
|
|
it('should return "warning" for 3rd place', () => {
|
|
expect(MedalFormatter.getVariant(3)).toBe('warning');
|
|
});
|
|
|
|
it('should return "low" for 4th place', () => {
|
|
expect(MedalFormatter.getVariant(4)).toBe('low');
|
|
});
|
|
|
|
it('should return "low" for any position after 3rd', () => {
|
|
expect(MedalFormatter.getVariant(5)).toBe('low');
|
|
expect(MedalFormatter.getVariant(10)).toBe('low');
|
|
expect(MedalFormatter.getVariant(100)).toBe('low');
|
|
});
|
|
});
|
|
|
|
describe('getMedalIcon', () => {
|
|
it('should return trophy for 1st place', () => {
|
|
expect(MedalFormatter.getMedalIcon(1)).toBe('🏆');
|
|
});
|
|
|
|
it('should return trophy for 2nd place', () => {
|
|
expect(MedalFormatter.getMedalIcon(2)).toBe('🏆');
|
|
});
|
|
|
|
it('should return trophy for 3rd place', () => {
|
|
expect(MedalFormatter.getMedalIcon(3)).toBe('🏆');
|
|
});
|
|
|
|
it('should return null for 4th place', () => {
|
|
expect(MedalFormatter.getMedalIcon(4)).toBeNull();
|
|
});
|
|
|
|
it('should return null for any position after 3rd', () => {
|
|
expect(MedalFormatter.getMedalIcon(5)).toBeNull();
|
|
expect(MedalFormatter.getMedalIcon(10)).toBeNull();
|
|
expect(MedalFormatter.getMedalIcon(100)).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('getBg', () => {
|
|
it('should return bg-warning-amber for 1st place', () => {
|
|
expect(MedalFormatter.getBg(1)).toBe('bg-warning-amber');
|
|
});
|
|
|
|
it('should return bg-gray-300 for 2nd place', () => {
|
|
expect(MedalFormatter.getBg(2)).toBe('bg-gray-300');
|
|
});
|
|
|
|
it('should return bg-orange-700 for 3rd place', () => {
|
|
expect(MedalFormatter.getBg(3)).toBe('bg-orange-700');
|
|
});
|
|
|
|
it('should return bg-gray-800 for 4th place', () => {
|
|
expect(MedalFormatter.getBg(4)).toBe('bg-gray-800');
|
|
});
|
|
|
|
it('should return bg-gray-800 for any position after 3rd', () => {
|
|
expect(MedalFormatter.getBg(5)).toBe('bg-gray-800');
|
|
expect(MedalFormatter.getBg(10)).toBe('bg-gray-800');
|
|
expect(MedalFormatter.getBg(100)).toBe('bg-gray-800');
|
|
});
|
|
});
|
|
|
|
describe('getColor', () => {
|
|
it('should return text-warning-amber for 1st place', () => {
|
|
expect(MedalFormatter.getColor(1)).toBe('text-warning-amber');
|
|
});
|
|
|
|
it('should return text-gray-300 for 2nd place', () => {
|
|
expect(MedalFormatter.getColor(2)).toBe('text-gray-300');
|
|
});
|
|
|
|
it('should return text-orange-700 for 3rd place', () => {
|
|
expect(MedalFormatter.getColor(3)).toBe('text-orange-700');
|
|
});
|
|
|
|
it('should return text-gray-400 for 4th place', () => {
|
|
expect(MedalFormatter.getColor(4)).toBe('text-gray-400');
|
|
});
|
|
|
|
it('should return text-gray-400 for any position after 3rd', () => {
|
|
expect(MedalFormatter.getColor(5)).toBe('text-gray-400');
|
|
expect(MedalFormatter.getColor(10)).toBe('text-gray-400');
|
|
expect(MedalFormatter.getColor(100)).toBe('text-gray-400');
|
|
});
|
|
});
|
|
});
|