Files
bsky-social-app/src/ageAssurance/util.test.ts
T
2026-08-13 22:13:50 +03:00

49 lines
1.3 KiB
TypeScript

import {getAgeAssuranceRegionConfigForGeolocation} from '#/ageAssurance/util'
import {type app} from '#/lexicons'
jest.mock('#/ageAssurance/data')
/*
* Platform scoping is applied locally in `util.ts` (the SDK region matcher
* takes no platform filter). The jest preset is `jest-expo/ios`, so
* `AGE_ASSURANCE_PLATFORM` resolves to `ios` in these tests.
*/
describe('getAgeAssuranceRegionConfigForGeolocation', () => {
const region = (
countryCode: string,
regionCode?: string,
platforms?: string[],
) =>
({
countryCode,
regionCode,
platforms,
minAccessAge: 13,
rules: [],
}) as app.bsky.ageassurance.defs.ConfigRegion
it('skips regions for other platforms and continues matching', () => {
const web = region('US', undefined, ['web'])
const ios = region('US', undefined, ['ios'])
expect(
getAgeAssuranceRegionConfigForGeolocation(
{regions: [web, ios]},
{countryCode: 'US', regionCode: undefined},
),
).toBe(ios)
})
it('matches a region-specific config before a later country config', () => {
const texas = region('US', 'TX')
const us = region('US')
expect(
getAgeAssuranceRegionConfigForGeolocation(
{regions: [texas, us]},
{countryCode: 'US', regionCode: 'TX'},
),
).toBe(texas)
})
})