diff --git a/src/components/AppNavigation.vue b/src/components/AppNavigation.vue index 75e3089..52663fa 100644 --- a/src/components/AppNavigation.vue +++ b/src/components/AppNavigation.vue @@ -92,6 +92,21 @@ function localRoute(path) { + + + + {{ $t('message.nav.events') }} + + + {{ $t('message.nav.partners') }} + + {{ $t('message.nav.events') }} + url.replace(/\/+$/, '') + +export const API_BASE = trim(window.__ENV__?.API_URL || 'https://api.beammp.com') +export const ACCOUNTS_BASE = trim(window.__ENV__?.ACCOUNTS_URL || 'https://accounts.beammp.com') diff --git a/src/locales/de.json b/src/locales/de.json index 7c36712..969e24d 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -22,7 +22,8 @@ "light": "Helles Theme", "dark": "Dunkles Theme", "system": "System-Theme" - } + }, + "events": "Events" }, "footer": { "support_on_patreon": "Unterstütze uns auf Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Gemeinsam bauen wir etwas Besonderes. Danke, dass du Teil der BeamMP-Community bist!" } + }, + "events": { + "title": "Events", + "description": "Verfolge die aktuellen Ranglisten der BeamMP-Events, zusammengeführt von allen teilnehmenden Servern.", + "loading": "Events werden geladen…", + "empty": "Es wurden noch keine Events eingerichtet.", + "viewTop": "Top {count} ansehen →", + "ranked": "Gewertete Fahrer: {count}", + "servers": "Server: {count}", + "back": "← Alle Events", + "loadingEvent": "Event wird geladen…", + "standings": "Gesamtwertung", + "topDrivers": "Top {count} Fahrer", + "statDrivers": "Gewertete Fahrer", + "statLaps": "Erfasste Runden", + "statServers": "Server", + "statPlace": "Platz {count}", + "standingsTitle": "Rangliste", + "search": "Fahrer suchen…", + "pos": "Pos", + "driver": "Fahrer", + "bestLap": "Beste Runde", + "gap": "Abstand", + "pen": "Str.", + "server": "Server", + "leader": "Führender", + "noMatch": "Keine passenden Fahrer.", + "waiting": "Warte auf die ersten Ergebnisse der Event-Server.", + "sources": "Server-Quellen", + "lastResult": "Letztes Ergebnis: {when}", + "none": "noch keins", + "noServers": "Noch kein Server ist beigetreten.", + "live": "Wird automatisch aktualisiert, sobald Server Runden melden.", + "lost": "Verbindung verloren. Neuer Versuch…", + "lastShown": "Zeige die zuletzt empfangenen Ergebnisse.", + "rules": "Event-Regeln", + "r1t": "Nur registrierte Fahrer.", + "r1": "Gäste werden nicht gewertet.", + "r2t": "Zeiten wie aufgezeichnet.", + "r2": "Strafen werden vom Spielserver verhängt; die angezeigte Zeit ist die von ihm gemeldete.", + "r3t": "Ein Platz pro Fahrer.", + "r3": "Beste Runde über alle Event-Server.", + "r4t": "Prüfung.", + "r4": "Das Team kann Fahrer nach einer Prüfung ausschließen.", + "status": { + "qualifying": "Qualifying", + "live": "Live-Event", + "upcoming": "Demnächst", + "finished": "Beendet" + }, + "errors": { + "notFound": "Dieses Event ist nicht verfügbar.", + "rateLimited": "Zu viele Anfragen. Neuer Versuch in Kürze.", + "unavailable": "Die Event-Ergebnisse sind nicht verfügbar.", + "timeout": "Zeitüberschreitung. Automatischer neuer Versuch." + } } } } diff --git a/src/locales/en.json b/src/locales/en.json index e6b59ea..ee0c4c8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -22,7 +22,8 @@ "light": "Light Theme", "dark": "Dark Theme", "system": "System Theme" - } + }, + "events": "Events" }, "footer": { "support_on_patreon": "Support us on Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Together, we’re building something special. Thank you for being part of the BeamMP community!" } + }, + "events": { + "title": "Events", + "description": "Follow the latest standings for BeamMP events, combined across every server taking part.", + "loading": "Loading events…", + "empty": "No events have been set up yet.", + "viewTop": "View top {count} →", + "ranked": "Ranked drivers: {count}", + "servers": "Servers: {count}", + "back": "← All events", + "loadingEvent": "Loading event…", + "standings": "Global standings", + "topDrivers": "Top {count} drivers", + "statDrivers": "Ranked drivers", + "statLaps": "Recorded laps", + "statServers": "Servers", + "statPlace": "Place {count}", + "standingsTitle": "Standings", + "search": "Search drivers…", + "pos": "Pos", + "driver": "Driver", + "bestLap": "Best lap", + "gap": "Gap", + "pen": "Pen.", + "server": "Server", + "leader": "Leader", + "noMatch": "No matching drivers.", + "waiting": "Waiting for the first results from event servers.", + "sources": "Server sources", + "lastResult": "Last result: {when}", + "none": "none yet", + "noServers": "No servers have joined yet.", + "live": "Updates automatically as servers report laps.", + "lost": "Connection lost. Retrying…", + "lastShown": "Showing the last received results.", + "rules": "Event rules", + "r1t": "Registered drivers only.", + "r1": "Guests are not ranked.", + "r2t": "Times as recorded.", + "r2": "Penalties are applied by the game server; the time shown is the time it reported.", + "r3t": "One place per driver.", + "r3": "Best lap across all event servers.", + "r4t": "Review.", + "r4": "Staff can exclude drivers after review.", + "status": { + "qualifying": "Qualifying", + "live": "Live event", + "upcoming": "Upcoming", + "finished": "Finished" + }, + "errors": { + "notFound": "This event is not available.", + "rateLimited": "Too many requests. Retrying shortly.", + "unavailable": "Event results are unavailable.", + "timeout": "Connection timed out. Retrying automatically." + } } } } diff --git a/src/locales/es.json b/src/locales/es.json index b149283..5377c89 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -22,7 +22,8 @@ "light": "Tema claro", "dark": "Tema oscuro", "system": "Tema del sistema" - } + }, + "events": "Eventos" }, "footer": { "support_on_patreon": "Apóyanos en Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Juntos estamos construyendo algo especial. ¡Gracias por ser parte de la comunidad BeamMP!" } + }, + "events": { + "title": "Eventos", + "description": "Sigue las clasificaciones de los eventos de BeamMP, combinadas de todos los servidores participantes.", + "loading": "Cargando eventos…", + "empty": "Aún no se ha creado ningún evento.", + "viewTop": "Ver el top {count} →", + "ranked": "Pilotos clasificados: {count}", + "servers": "Servidores: {count}", + "back": "← Todos los eventos", + "loadingEvent": "Cargando evento…", + "standings": "Clasificación global", + "topDrivers": "Top {count} pilotos", + "statDrivers": "Pilotos clasificados", + "statLaps": "Vueltas registradas", + "statServers": "Servidores", + "statPlace": "Puesto {count}", + "standingsTitle": "Clasificación", + "search": "Buscar pilotos…", + "pos": "Pos", + "driver": "Piloto", + "bestLap": "Mejor vuelta", + "gap": "Diferencia", + "pen": "Pen.", + "server": "Servidor", + "leader": "Líder", + "noMatch": "Ningún piloto coincide.", + "waiting": "Esperando los primeros resultados de los servidores del evento.", + "sources": "Servidores de origen", + "lastResult": "Último resultado: {when}", + "none": "aún ninguno", + "noServers": "Aún no se ha unido ningún servidor.", + "live": "Se actualiza automáticamente cuando los servidores informan de vueltas.", + "lost": "Conexión perdida. Reintentando…", + "lastShown": "Mostrando los últimos resultados recibidos.", + "rules": "Reglas del evento", + "r1t": "Solo pilotos registrados.", + "r1": "Los invitados no se clasifican.", + "r2t": "Tiempos tal como se registran.", + "r2": "El servidor del juego aplica las penalizaciones; el tiempo mostrado es el que informó.", + "r3t": "Un puesto por piloto.", + "r3": "Mejor vuelta en todos los servidores del evento.", + "r4t": "Revisión.", + "r4": "El personal puede excluir pilotos tras revisarlos.", + "status": { + "qualifying": "Clasificación previa", + "live": "Evento en vivo", + "upcoming": "Próximamente", + "finished": "Finalizado" + }, + "errors": { + "notFound": "Este evento no está disponible.", + "rateLimited": "Demasiadas solicitudes. Reintentando en breve.", + "unavailable": "Los resultados del evento no están disponibles.", + "timeout": "Se agotó el tiempo de conexión. Reintentando automáticamente." + } } } } diff --git a/src/locales/fr.json b/src/locales/fr.json index 0261852..f4e46af 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -22,7 +22,8 @@ "light": "Thème clair", "dark": "Thème sombre", "system": "Thème système" - } + }, + "events": "Événements" }, "footer": { "support_on_patreon": "Soutenez-nous sur notre Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Ensemble, nous construisons quelque chose de spécial. Merci de faire partie de la communauté BeamMP !" } + }, + "events": { + "title": "Événements", + "description": "Suivez les classements des événements BeamMP, regroupés depuis tous les serveurs participants.", + "loading": "Chargement des événements…", + "empty": "Aucun événement n'a encore été créé.", + "viewTop": "Voir le top {count} →", + "ranked": "Pilotes classés: {count}", + "servers": "Serveurs: {count}", + "back": "← Tous les événements", + "loadingEvent": "Chargement de l'événement…", + "standings": "Classement général", + "topDrivers": "Top {count} pilotes", + "statDrivers": "Pilotes classés", + "statLaps": "Tours enregistrés", + "statServers": "Serveurs", + "statPlace": "Place {count}", + "standingsTitle": "Classement", + "search": "Rechercher un pilote…", + "pos": "Pos", + "driver": "Pilote", + "bestLap": "Meilleur tour", + "gap": "Écart", + "pen": "Pén.", + "server": "Serveur", + "leader": "Leader", + "noMatch": "Aucun pilote correspondant.", + "waiting": "En attente des premiers résultats des serveurs de l'événement.", + "sources": "Serveurs sources", + "lastResult": "Dernier résultat : {when}", + "none": "aucun pour l'instant", + "noServers": "Aucun serveur n'a encore rejoint l'événement.", + "live": "Mise à jour automatique à mesure que les serveurs envoient des tours.", + "lost": "Connexion perdue. Nouvelle tentative…", + "lastShown": "Affichage des derniers résultats reçus.", + "rules": "Règles de l'événement", + "r1t": "Pilotes enregistrés uniquement.", + "r1": "Les invités ne sont pas classés.", + "r2t": "Temps tels qu'enregistrés.", + "r2": "Les pénalités sont appliquées par le serveur de jeu ; le temps affiché est celui qu'il a transmis.", + "r3t": "Une place par pilote.", + "r3": "Meilleur tour sur tous les serveurs de l'événement.", + "r4t": "Vérification.", + "r4": "Le staff peut exclure des pilotes après examen.", + "status": { + "qualifying": "Qualifications", + "live": "Événement en direct", + "upcoming": "À venir", + "finished": "Terminé" + }, + "errors": { + "notFound": "Cet événement n'est pas disponible.", + "rateLimited": "Trop de requêtes. Nouvelle tentative sous peu.", + "unavailable": "Les résultats de l'événement sont indisponibles.", + "timeout": "Délai de connexion dépassé. Nouvelle tentative automatique." + } } } } diff --git a/src/locales/it.json b/src/locales/it.json index cee3786..c3e36bd 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -22,7 +22,8 @@ "light": "Tema chiaro", "dark": "Tema scuro", "system": "Tema di sistema" - } + }, + "events": "Eventi" }, "footer": { "support_on_patreon": "Supportaci su Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Insieme stiamo costruendo qualcosa di speciale. Grazie per far parte della community BeamMP!" } + }, + "events": { + "title": "Eventi", + "description": "Segui le classifiche degli eventi BeamMP, riunite da tutti i server partecipanti.", + "loading": "Caricamento eventi…", + "empty": "Nessun evento è stato ancora creato.", + "viewTop": "Vedi la top {count} →", + "ranked": "Piloti in classifica: {count}", + "servers": "Server: {count}", + "back": "← Tutti gli eventi", + "loadingEvent": "Caricamento evento…", + "standings": "Classifica globale", + "topDrivers": "Top {count} piloti", + "statDrivers": "Piloti in classifica", + "statLaps": "Giri registrati", + "statServers": "Server", + "statPlace": "Posizione {count}", + "standingsTitle": "Classifica", + "search": "Cerca piloti…", + "pos": "Pos", + "driver": "Pilota", + "bestLap": "Giro migliore", + "gap": "Distacco", + "pen": "Pen.", + "server": "Server", + "leader": "Leader", + "noMatch": "Nessun pilota corrispondente.", + "waiting": "In attesa dei primi risultati dai server dell'evento.", + "sources": "Server di origine", + "lastResult": "Ultimo risultato: {when}", + "none": "ancora nessuno", + "noServers": "Nessun server si è ancora unito.", + "live": "Si aggiorna automaticamente quando i server inviano giri.", + "lost": "Connessione persa. Nuovo tentativo…", + "lastShown": "Mostro gli ultimi risultati ricevuti.", + "rules": "Regole dell'evento", + "r1t": "Solo piloti registrati.", + "r1": "Gli ospiti non vengono classificati.", + "r2t": "Tempi come registrati.", + "r2": "Le penalità sono applicate dal server di gioco; il tempo mostrato è quello da lui comunicato.", + "r3t": "Un posto per pilota.", + "r3": "Giro migliore su tutti i server dell'evento.", + "r4t": "Revisione.", + "r4": "Lo staff può escludere piloti dopo una verifica.", + "status": { + "qualifying": "Qualifiche", + "live": "Evento live", + "upcoming": "In arrivo", + "finished": "Concluso" + }, + "errors": { + "notFound": "Questo evento non è disponibile.", + "rateLimited": "Troppe richieste. Nuovo tentativo a breve.", + "unavailable": "I risultati dell'evento non sono disponibili.", + "timeout": "Connessione scaduta. Nuovo tentativo automatico." + } } } } diff --git a/src/locales/ru.json b/src/locales/ru.json index 4476dfe..c5a3a6c 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -22,7 +22,8 @@ "light": "Светлая тема", "dark": "Тёмная тема", "system": "Системная тема" - } + }, + "events": "События" }, "footer": { "support_on_patreon": "Поддержите нас на Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "Вместе мы строим нечто особенное. Спасибо, что вы — часть сообщества BeamMP!" } + }, + "events": { + "title": "События", + "description": "Следите за актуальными таблицами результатов событий BeamMP, объединёнными со всех участвующих серверов.", + "loading": "Загрузка событий…", + "empty": "События ещё не созданы.", + "viewTop": "Смотреть топ-{count} →", + "ranked": "Пилотов в рейтинге: {count}", + "servers": "Серверы: {count}", + "back": "← Все события", + "loadingEvent": "Загрузка события…", + "standings": "Общий зачёт", + "topDrivers": "Топ-{count} пилотов", + "statDrivers": "Пилотов в рейтинге", + "statLaps": "Записано кругов", + "statServers": "Серверы", + "statPlace": "{count}-е место", + "standingsTitle": "Таблица", + "search": "Поиск пилотов…", + "pos": "Поз", + "driver": "Пилот", + "bestLap": "Лучший круг", + "gap": "Отставание", + "pen": "Штр.", + "server": "Сервер", + "leader": "Лидер", + "noMatch": "Подходящих пилотов нет.", + "waiting": "Ожидание первых результатов от серверов события.", + "sources": "Серверы-источники", + "lastResult": "Последний результат: {when}", + "none": "пока нет", + "noServers": "Ни один сервер ещё не присоединился.", + "live": "Обновляется автоматически, когда серверы присылают круги.", + "lost": "Соединение потеряно. Повторная попытка…", + "lastShown": "Показаны последние полученные результаты.", + "rules": "Правила события", + "r1t": "Только зарегистрированные пилоты.", + "r1": "Гости не учитываются в рейтинге.", + "r2t": "Время как записано.", + "r2": "Штрафы применяет игровой сервер; показано время, которое он передал.", + "r3t": "Одно место на пилота.", + "r3": "Лучший круг среди всех серверов события.", + "r4t": "Проверка.", + "r4": "Персонал может исключать пилотов после проверки.", + "status": { + "qualifying": "Квалификация", + "live": "Событие в прямом эфире", + "upcoming": "Скоро", + "finished": "Завершено" + }, + "errors": { + "notFound": "Это событие недоступно.", + "rateLimited": "Слишком много запросов. Скоро повторим попытку.", + "unavailable": "Результаты события недоступны.", + "timeout": "Превышено время ожидания. Повтор автоматически." + } } } } diff --git a/src/locales/zh.json b/src/locales/zh.json index 63d9c56..6bc78e1 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -22,7 +22,8 @@ "light": "明亮主题", "dark": "黑暗主题", "system": "跟随系统" - } + }, + "events": "赛事" }, "footer": { "support_on_patreon": "Patreon", @@ -274,6 +275,62 @@ }, "thank_you": "我们正在共同打造一个独特的作品—真诚感谢您成为BeamMP社区的一员!" } + }, + "events": { + "title": "赛事", + "description": "查看 BeamMP 赛事的最新排名,汇总所有参赛服务器的成绩。", + "loading": "正在加载赛事…", + "empty": "尚未创建任何赛事。", + "viewTop": "查看前 {count} 名 →", + "ranked": "已排名车手: {count}", + "servers": "服务器: {count}", + "back": "← 全部赛事", + "loadingEvent": "正在加载赛事…", + "standings": "总排名", + "topDrivers": "前 {count} 名车手", + "statDrivers": "已排名车手", + "statLaps": "已记录圈数", + "statServers": "服务器", + "statPlace": "第 {count} 名", + "standingsTitle": "排名", + "search": "搜索车手…", + "pos": "名次", + "driver": "车手", + "bestLap": "最佳圈速", + "gap": "差距", + "pen": "罚", + "server": "服务器", + "leader": "领先", + "noMatch": "没有匹配的车手。", + "waiting": "正在等待赛事服务器的首批成绩。", + "sources": "服务器来源", + "lastResult": "最近成绩:{when}", + "none": "暂无", + "noServers": "尚无服务器加入。", + "live": "服务器上报圈速后自动更新。", + "lost": "连接已断开,正在重试…", + "lastShown": "显示最近收到的成绩。", + "rules": "赛事规则", + "r1t": "仅限注册车手。", + "r1": "访客不计入排名。", + "r2t": "按记录计时。", + "r2": "处罚由游戏服务器执行;显示的是其上报的时间。", + "r3t": "每位车手一个名次。", + "r3": "取所有赛事服务器中的最佳圈速。", + "r4t": "审核。", + "r4": "工作人员可在审核后排除车手。", + "status": { + "qualifying": "排位赛", + "live": "直播赛事", + "upcoming": "即将开始", + "finished": "已结束" + }, + "errors": { + "notFound": "此赛事不可用。", + "rateLimited": "请求过多,稍后重试。", + "unavailable": "赛事成绩暂不可用。", + "timeout": "连接超时,正在自动重试。" + } } } } diff --git a/src/routes/index.js b/src/routes/index.js index 93fd67e..5830db5 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -66,6 +66,27 @@ const baseRoutes = [ }, }, + { + path: 'events', + name: 'Events', + component: () => import('@/views/events/EventList.vue'), + meta: { + title: 'Events - BeamMP', + description: 'Live standings for BeamMP events', + requiresAuth: false, + }, + }, + { + path: 'events/:eventId', + name: 'EventDetail', + component: () => import('@/views/events/EventDetail.vue'), + meta: { + title: 'Event standings - BeamMP', + description: 'Live standings for a BeamMP event', + requiresAuth: false, + }, + }, + { path: 'privacy', name: 'Privacy', diff --git a/src/views/events/EventDetail.vue b/src/views/events/EventDetail.vue new file mode 100644 index 0000000..c69dfe2 --- /dev/null +++ b/src/views/events/EventDetail.vue @@ -0,0 +1,236 @@ + + + diff --git a/src/views/events/EventList.vue b/src/views/events/EventList.vue new file mode 100644 index 0000000..d5f4585 --- /dev/null +++ b/src/views/events/EventList.vue @@ -0,0 +1,114 @@ + + + diff --git a/src/views/events/helpers.js b/src/views/events/helpers.js new file mode 100644 index 0000000..e820eca --- /dev/null +++ b/src/views/events/helpers.js @@ -0,0 +1,104 @@ +import { onBeforeUnmount, onMounted, ref } from 'vue' +import { useI18n } from 'vue-i18n' +import { API_BASE } from '@/lib/config' + +/** Seconds to m:ss.mmm, as shown on the boards. */ +export function formatLap(value) { + const ms = Math.round(value * 1000) + return `${Math.floor(ms / 60000)}:${String(Math.floor(ms / 1000) % 60).padStart(2, '0')}.${String(ms % 1000).padStart(3, '0')}` +} + +export function formatWhen(value) { + return value + ? new Date(value) + .toISOString() + .replace('T', ' ') + .replace(/\.\d+Z$/, ' UTC') + : null +} + +/** + * Polls one public events path and keeps the last good result on screen if a refresh fails. + * The path (/v1/events/...) is served by the main API at API_BASE, which holds the read key, so no key + * ever reaches the browser. + */ +export function useEventsFeed(pathGetter, { intervalMs = 2000 } = {}) { + const data = ref(null) + const error = ref('') + const connected = ref(false) + let timer + let controller + let generation = 0 + let stopped = false + + async function refresh() { + const token = ++generation + controller?.abort() + const mine = new window.AbortController() + controller = mine + const timeout = window.setTimeout(() => mine.abort(), 7000) + try { + const res = await fetch(`${API_BASE}${pathGetter()}`, { + cache: 'no-store', + signal: mine.signal, + }) + if (!res.ok) { + throw new Error( + res.status === 404 ? 'notFound' : res.status === 429 ? 'rateLimited' : 'unavailable' + ) + } + const json = await res.json() + if (token !== generation || stopped) return + data.value = json + error.value = '' + connected.value = true + } catch (failure) { + if (token !== generation || stopped) return + connected.value = false + error.value = failure.name === 'AbortError' ? 'timeout' : failure.message + } finally { + window.clearTimeout(timeout) + if (token === generation && !stopped) timer = window.setTimeout(refresh, intervalMs) + } + } + + function restart() { + window.clearTimeout(timer) + data.value = null + refresh() + } + + onMounted(refresh) + onBeforeUnmount(() => { + stopped = true + window.clearTimeout(timer) + controller?.abort() + }) + return { data, error, connected, restart } +} + +/** Translated status and error text. The keys are written out so the locale check can see them. */ +export function useEventText() { + const { t } = useI18n() + const status = (value) => + ({ + qualifying: t('message.events.status.qualifying'), + live: t('message.events.status.live'), + upcoming: t('message.events.status.upcoming'), + finished: t('message.events.status.finished'), + })[value] ?? value + const errorText = (code) => + ({ + notFound: t('message.events.errors.notFound'), + rateLimited: t('message.events.errors.rateLimited'), + timeout: t('message.events.errors.timeout'), + })[code] ?? t('message.events.errors.unavailable') + return { status, errorText } +} + +/** Address of an event's banner image, or null when it has none. Images are served by the main API. */ +export function bannerSrc(event, size) { + const version = event?.bannerVersion + if (!version) return null + return `${API_BASE}/v1/event-banners/${encodeURIComponent(event.id)}/${encodeURIComponent(version)}/${size}` +} diff --git a/tests/events.test.js b/tests/events.test.js new file mode 100644 index 0000000..b14676f --- /dev/null +++ b/tests/events.test.js @@ -0,0 +1,21 @@ +import { describe, expect, test } from 'vitest' +import { bannerSrc, formatLap } from '@/views/events/helpers' + +describe('event helpers', () => { + test('banner address is built on the main API from the event id and version', () => { + const version = 'a'.repeat(32) + expect(bannerSrc({ id: 'hirochi', bannerVersion: version }, 'card')).toMatch( + new RegExp(`/v1/event-banners/hirochi/${version}/card$`) + ) + expect(bannerSrc({ id: 'a/b', bannerVersion: 'v 1' }, 'hero')).toMatch(/\/a%2Fb\/v%201\/hero$/) + }) + test('an event without a banner has no address', () => { + expect(bannerSrc({ id: 'x', bannerVersion: null }, 'card')).toBeNull() + expect(bannerSrc({ id: 'x' }, 'hero')).toBeNull() + expect(bannerSrc(undefined, 'hero')).toBeNull() + }) + test('lap times are shown as m:ss.mmm', () => { + expect(formatLap(80.122)).toBe('1:20.122') + expect(formatLap(59.9996)).toBe('1:00.000') + }) +})