fix: complete jump-hop frontend wiring
This commit is contained in:
26
src/services/publicWorkCode.test.ts
Normal file
26
src/services/publicWorkCode.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
buildJumpHopPublicWorkCode,
|
||||
isSameJumpHopPublicWorkCode,
|
||||
} from './publicWorkCode';
|
||||
|
||||
describe('publicWorkCode', () => {
|
||||
it('builds and matches jump-hop public work codes from profile ids', () => {
|
||||
expect(buildJumpHopPublicWorkCode('jump-hop-profile-12345678')).toBe(
|
||||
'JH-12345678',
|
||||
);
|
||||
expect(
|
||||
isSameJumpHopPublicWorkCode(
|
||||
'jh-12345678',
|
||||
'jump-hop-profile-12345678',
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isSameJumpHopPublicWorkCode(
|
||||
'jump hop profile 12345678',
|
||||
'jump-hop-profile-12345678',
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -67,6 +67,14 @@ export function buildBarkBattlePublicWorkCode(workId: string) {
|
||||
return `BB-${normalizeBarkBattlePublicWorkCodeSuffix(workId)}`;
|
||||
}
|
||||
|
||||
export function buildJumpHopPublicWorkCode(profileId: string) {
|
||||
const normalized = normalizePublicCodeText(profileId);
|
||||
const fallback = normalized || '00000000';
|
||||
const suffix = fallback.slice(-8).padStart(8, '0');
|
||||
|
||||
return `JH-${suffix}`;
|
||||
}
|
||||
|
||||
export function isSamePuzzlePublicWorkCode(keyword: string, profileId: string) {
|
||||
const normalizedKeyword = normalizePublicCodeText(keyword);
|
||||
|
||||
@@ -149,3 +157,13 @@ export function isSameBarkBattlePublicWorkCode(keyword: string, workId: string)
|
||||
normalizedKeyword === normalizeBarkBattlePublicWorkCodeSuffix(workId)
|
||||
);
|
||||
}
|
||||
|
||||
export function isSameJumpHopPublicWorkCode(keyword: string, profileId: string) {
|
||||
const normalizedKeyword = normalizePublicCodeText(keyword);
|
||||
|
||||
return (
|
||||
normalizedKeyword ===
|
||||
normalizePublicCodeText(buildJumpHopPublicWorkCode(profileId)) ||
|
||||
normalizedKeyword === normalizePublicCodeText(profileId)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user