mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-16 02:22:17 +00:00
b2b750115f
Every grid cell downloaded the full detail sprite. Generate a smaller /sprites-grid/v1/ set at build time and let the grid ask for those first, falling back through the existing detail URLs when a thumbnail is missing so detail resolution is unchanged. The new prefix is versioned, so it can be cached forever, and the service worker recognises it alongside the other sprite roots. The placeholder is now an empty box rather than a spinner: a thousand spinners cost layout work and announced nothing useful.
25 lines
994 B
TypeScript
25 lines
994 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { resolveGridSpriteUrl, resolveSpriteUrl } from '$lib/utils/spriteUrl';
|
|
|
|
describe('versioned grid artwork', () => {
|
|
it('separates grid and detail URLs for shiny, female and named forms', () => {
|
|
for (const form of ['', 'Female', 'Alolan', 'Female Mega']) {
|
|
for (const shiny of [false, true]) {
|
|
const entry = { pokedexNumber: 25, form, spriteKey: '25' };
|
|
const grid = resolveGridSpriteUrl(entry, shiny);
|
|
expect(grid).toBe(
|
|
resolveSpriteUrl(entry, shiny, true).replace(
|
|
'/sprites-small/home/',
|
|
'/sprites-grid/v1/home/'
|
|
)
|
|
);
|
|
expect(resolveSpriteUrl(entry, shiny, true)).not.toContain('sprites-grid');
|
|
}
|
|
}
|
|
});
|
|
// Source-to-output consistency is checked when artifacts are built, not required for a fresh unit-only checkout.
|
|
it('keeps the grid sprite URL version explicit', () => {
|
|
expect(resolveGridSpriteUrl({ pokedexNumber: 1 }, false)).toBe('/sprites-grid/v1/home/1.webp');
|
|
});
|
|
});
|