Say what is in a section when confirming its deletion
Closes #13 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -162,3 +162,32 @@ test('header revert restores the default (absent) and a custom header', () => {
|
||||
assert.notEqual(d.header.fields[0].text, 'changed');
|
||||
assert.notEqual(d.header, base.header); // a copy, not shared
|
||||
});
|
||||
|
||||
// ---- delete-section confirmation ----
|
||||
import { sectionContents, deleteSectionMessage, addSequence, addFrame } from '../src/ops.js';
|
||||
const PNGX = 'data:image/png;base64,iVBORw0KGgo=';
|
||||
|
||||
test('deleteSectionMessage names the section and counts what is in it', () => {
|
||||
const d = emptyDocument('o');
|
||||
const s = addSection(d, 'records', 'Bank Accounts');
|
||||
assert.equal(deleteSectionMessage(s), 'Delete the empty section "Bank Accounts"?');
|
||||
const r1 = addRecord(d, s); addRecord(d, s);
|
||||
r1.fields.push({ kind: 'image', label: 'ID', value: PNGX }, { kind: 'image', label: 'blank', value: '' }, { label: 'a', value: 'b' });
|
||||
const q = addSequence(d, s); addFrame(q, PNGX); addFrame(q, '');
|
||||
assert.deepEqual(sectionContents(s), { records: 2, items: 0, sequences: 1, images: 2, text: false });
|
||||
assert.equal(deleteSectionMessage(s),
|
||||
'Delete the section "Bank Accounts" and everything in it (2 records, 1 visual sequence, 2 images)? This cannot be undone with Cancel.');
|
||||
});
|
||||
|
||||
test('deleteSectionMessage: items, singular forms, and text sections', () => {
|
||||
const d = emptyDocument('o');
|
||||
const c = addSection(d, 'checklist', 'To do'); addItem(d, c);
|
||||
const q = addSequence(d, c); addFrame(q, PNGX); addFrame(q, PNGX);
|
||||
assert.match(deleteSectionMessage(c), /\(1 item, 1 visual sequence, 2 images\)/);
|
||||
const t = addSection(d, 'text', 'Start');
|
||||
assert.match(deleteSectionMessage(t), /^Delete the empty section "Start"\?$/);
|
||||
t.body = 'hello';
|
||||
assert.match(deleteSectionMessage(t), /\(its text\)/);
|
||||
addSequence(d, t);
|
||||
assert.match(deleteSectionMessage(t), /\(1 visual sequence, its text\)/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user