mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-14 17:42:17 +00:00
test(pokedex): cover shared dex privacy
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { calculateSharedProgress, isShareToken } from '$lib/services/SharedPokedexService';
|
||||
|
||||
describe('shared Pokédex helpers', () => {
|
||||
it('accepts UUID capability tokens and rejects malformed route values', () => {
|
||||
expect(isShareToken('123e4567-e89b-42d3-a456-426614174000')).toBe(true);
|
||||
expect(isShareToken('not-a-token')).toBe(false);
|
||||
expect(isShareToken('123e4567-e89b-12d3-a456-426614174000/extra')).toBe(false);
|
||||
});
|
||||
|
||||
it('counts caught and needs-to-evolve entries as progress', () => {
|
||||
const progress = calculateSharedProgress(
|
||||
[
|
||||
{
|
||||
pokemonId: '1',
|
||||
caught: true,
|
||||
haveToEvolve: false,
|
||||
inHome: false,
|
||||
hasGigantamaxed: false
|
||||
},
|
||||
{
|
||||
pokemonId: '2',
|
||||
caught: false,
|
||||
haveToEvolve: true,
|
||||
inHome: false,
|
||||
hasGigantamaxed: false
|
||||
}
|
||||
],
|
||||
4
|
||||
);
|
||||
expect(progress).toEqual({ caught: 2, completionPercentage: 50 });
|
||||
expect(calculateSharedProgress([], 0)).toEqual({ caught: 0, completionPercentage: 0 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user