Add notepad text import export
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
This commit is contained in:
parent
323e1b266d
commit
f76cddcc95
8 changed files with 165 additions and 19 deletions
|
|
@ -11,6 +11,7 @@ function createTextImportContext() {
|
|||
let index = 0;
|
||||
return {
|
||||
uid: (prefix) => `${prefix}-${index += 1}`,
|
||||
normalizeNotepadData,
|
||||
normalizeChecklistData,
|
||||
normalizeLinksData,
|
||||
normalizeCountersData,
|
||||
|
|
@ -40,6 +41,23 @@ test("colon text import accepts labels without value", () => {
|
|||
|
||||
test("text exchange round trips simple toolbox modules and resets checklist progress", () => {
|
||||
const context = createTextImportContext();
|
||||
const notepad = normalizeNotepadData({
|
||||
html: '<h3>Route</h3><p><strong style="color: #f6c453">Boss</strong></p>',
|
||||
drawingMode: "permanent",
|
||||
drawings: {
|
||||
strokes: [
|
||||
{ id: "old-stroke", color: "#22d3ee", width: 4, points: [{ x: 2, y: 3 }, { x: 8, y: 13 }] }
|
||||
]
|
||||
}
|
||||
});
|
||||
const notepadImport = importModuleText("notepad", exportModuleText("notepad", notepad), context);
|
||||
assert.equal(notepadImport.ok, true);
|
||||
assert.match(notepadImport.data.html, /<h3>Route<\/h3>/);
|
||||
assert.match(notepadImport.data.html, /<strong style="color: #f6c453">Boss<\/strong>/);
|
||||
assert.equal(notepadImport.data.drawingMode, "permanent");
|
||||
assert.equal(notepadImport.data.drawings.strokes.length, 1);
|
||||
assert.notEqual(notepadImport.data.drawings.strokes[0].id, "old-stroke");
|
||||
|
||||
const checklist = normalizeChecklistData({
|
||||
sections: [
|
||||
{
|
||||
|
|
@ -169,6 +187,8 @@ test("text exchange rejects invalid imports without data", () => {
|
|||
assert.match(invalidImage.error, /^Ligne 1:/);
|
||||
assert.equal(invalidMarker.ok, false);
|
||||
assert.match(invalidMarker.error, /^Ligne 2:/);
|
||||
assert.equal(importModuleText("notepad", "@notepad\n@html\n<p>Note</p>", context).ok, false);
|
||||
assert.equal(importModuleText("notepad", "@notepad\n@drawings: {bad}", context).ok, false);
|
||||
assert.equal(importModuleText("table", "\n", context).ok, false);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue