chore(claude-do): merge fix(localization): make the locale-parity test actually able
ClaudeDo-Task: dee67d25-ac34-4a71-b71d-6bbb1130943f
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Text.Json;
|
||||
using ClaudeDo.Localization;
|
||||
|
||||
namespace ClaudeDo.Localization.Tests;
|
||||
@@ -16,10 +17,34 @@ public class EnJsonCoverageTests
|
||||
throw new DirectoryNotFoundException("Could not locate src/ClaudeDo.Localization/locales");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void All_locale_files_parse_as_valid_json()
|
||||
{
|
||||
var localesDir = LocalesDir();
|
||||
foreach (var path in Directory.EnumerateFiles(localesDir, "*.json"))
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonDocument.Parse(File.ReadAllText(path));
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
Assert.Fail($"{Path.GetFileName(path)} is not valid JSON: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Every_locale_has_same_keys_as_english()
|
||||
{
|
||||
var store = LocaleStore.Load(LocalesDir());
|
||||
var localesDir = LocalesDir();
|
||||
var jsonFileCount = Directory.EnumerateFiles(localesDir, "*.json").Count();
|
||||
var store = LocaleStore.Load(localesDir);
|
||||
Assert.True(store.Available.Count == jsonFileCount,
|
||||
$"Expected {jsonFileCount} locale(s) to load from {localesDir}, but only {store.Available.Count} loaded " +
|
||||
$"(loaded: {string.Join(", ", store.Available.Select(l => l.Code))}). A *.json file failed to parse.");
|
||||
Assert.True(store.TryGet("de", out _), "Locale 'de' did not load — de.json failed to parse.");
|
||||
|
||||
Assert.True(store.TryGet("en", out var en));
|
||||
var enKeys = en!.Strings.Keys.ToHashSet();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user