getExtension(), ['ts', 'tsx'], true)) { continue; } foreach (file($file->getPathname()) as $number => $line) { if (preg_match($pattern, $line) === 1) { $offenders[] = str_replace($root.'/', '', $file->getPathname()).':'.($number + 1); } } } test('the raw locale key is never handed to Intl', function () use ($offenders) { expect($offenders)->toBe([], implode("\n", array_merge( ['These pass the app locale straight to Intl, which throws on keys like zh_CN and blanks the page.'], ['Wrap it: intlLocale(locale) — see resources/js/lib/intl-locale.ts.'], $offenders, ))); }); test('intlLocale converts catalogue keys and refuses nonsense', function () use ($root) { $source = file_get_contents($root.'/resources/js/lib/intl-locale.ts'); // The helper the test above points people at has to keep existing, and // has to keep doing the two things that matter: swap the separator, and // never throw. expect($source) ->toContain("replace(/_/g, '-')") ->toContain('Intl.getCanonicalLocales') ->toContain('return undefined'); });