PronounsPage/test/plugins/track.test.ts
Valentyne Stigloher b7e72cfcb4 (plausible) simplify redaction code and strip hashes
instances for hashes which show up in plausible include #google_vignette (from ads), pronouns after profile or search filters in lists
2024-03-18 14:04:38 +01:00

25 lines
1.0 KiB
TypeScript

import { describe, expect, test } from '@jest/globals';
import { normalizeUrl } from '../../plugins/track.ts';
describe('when tracking', () => {
const base = 'https://pronouns.page';
test('normal pages are tracked verbatim', () => {
expect(normalizeUrl(new URL('/pronouns', base))).toEqual(new URL('/pronouns', base));
});
test.each([
{ given: '/@example', expected: '/@--redacted--' },
{ given: '/u/example', expected: '/u/--redacted--' },
{ given: '/card/example', expected: '/card/--redacted--' },
])('pages containing user name are redacted', ({ given, expected }) => {
expect(normalizeUrl(new URL(given, base))).toEqual(new URL(expected, base));
});
test.each([
{ given: '/terminology#queer', expected: '/terminology' },
{ given: '/@example#they/them', expected: '/@--redacted--' },
])('hashes are stripped', ({ given, expected }) => {
expect(normalizeUrl(new URL(given, base))).toEqual(new URL(expected, base));
});
});