mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-28 19:01:34 +00:00
test: the JSON-details contract counts both branches (#42)
User-Visible: no Issue: #42
This commit is contained in:
@@ -102,7 +102,8 @@ test('passage UI copy is bilingual and carries matching placeholders', () => {
|
||||
test('#42 _errText parses JSON details first and falls back code-first', () => {
|
||||
const card = readFileSync(new URL('../src/houseplan-card.ts', import.meta.url), 'utf8');
|
||||
const errText = card.slice(card.indexOf('private _errText('), card.indexOf('private _backupErrorText('));
|
||||
assert.match(errText, /JSON\.parse\(raw\)/, 'structured details are parsed as JSON');
|
||||
assert.equal((errText.match(/JSON\.parse\(raw\)/g) || []).length, 2,
|
||||
'BOTH structured-details branches (passage fields and jamb margin) parse JSON first');
|
||||
assert.match(errText, /space=\(\[\^;\]\*\)/, 'the legacy regex stays as one-beta read-compat');
|
||||
assert.ok(errText.indexOf('if (e.code != null)') < errText.indexOf('if (e.message) return e.message'),
|
||||
'code-first: a coded backend error localizes before any raw message');
|
||||
|
||||
Reference in New Issue
Block a user