Skip to content

Commit 2b1b02f

Browse files
committed
chore: fix erroneous imports
1 parent 028dcbc commit 2b1b02f

File tree

11 files changed

+6575
-11950
lines changed

11 files changed

+6575
-11950
lines changed

Editor.spec.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
isValidInsert,
1111
remove,
1212
sclDocString,
13-
setAttribute,
13+
setAttributes,
1414
setTextContent,
1515
testDocs,
1616
UndoRedoTestCase,
@@ -20,7 +20,7 @@ import {
2020

2121
import { newEditEventV2 } from "./edit-event.js";
2222

23-
import { EditV2, isSetAttributes, isSetTextContent } from "./handleEdit.js";
23+
import { EditV2, isSetAttributes, isSetTextContent } from "./editv2.js";
2424

2525
import { Editor } from "./Editor.js";
2626

@@ -42,7 +42,7 @@ describe("Utility function to handle EditV2 edits", () => {
4242
editor.dispatchEvent(newEditEventV2({ parent, node, reference }, {}));
4343
expect(sclDoc.documentElement.querySelector("test")).to.have.property(
4444
"nextSibling",
45-
reference
45+
reference,
4646
);
4747
});
4848

@@ -79,8 +79,8 @@ describe("Utility function to handle EditV2 edits", () => {
7979
},
8080
},
8181
},
82-
{}
83-
)
82+
{},
83+
),
8484
);
8585

8686
expect(element.getAttribute("name")).to.equal("A2");
@@ -102,7 +102,7 @@ describe("Utility function to handle EditV2 edits", () => {
102102
newEditEventV2({
103103
element,
104104
textContent: newTextContent,
105-
})
105+
}),
106106
);
107107

108108
expect(element.textContent).to.equal(newTextContent);
@@ -163,16 +163,16 @@ describe("Utility function to handle EditV2 edits", () => {
163163
{ parent, node: node1, reference },
164164
{ parent, node: node2, reference },
165165
],
166-
{}
167-
)
166+
{},
167+
),
168168
);
169169
expect(sclDoc.documentElement.querySelector("test1")).to.have.property(
170170
"nextSibling",
171-
node2
171+
node2,
172172
);
173173
expect(sclDoc.documentElement.querySelector("test2")).to.have.property(
174174
"nextSibling",
175-
reference
175+
reference,
176176
);
177177

178178
expect(editor.docVersion).to.equal(1);
@@ -215,8 +215,8 @@ describe("Utility function to handle EditV2 edits", () => {
215215
edit.node.nextSibling === edit.reference
216216
);
217217
return true;
218-
}
219-
)
218+
},
219+
),
220220
));
221221

222222
it("set's an element's textContent on SetTextContent edit events", () =>
@@ -230,26 +230,26 @@ describe("Utility function to handle EditV2 edits", () => {
230230
editor.dispatchEvent(newEditEventV2(edit));
231231

232232
return edit.element.textContent === edit.textContent;
233-
}
234-
)
233+
},
234+
),
235235
));
236236

237237
it("updates default- and foreign-namespace attributes on UpdateNS events", () =>
238238
assert(
239239
property(
240-
testDocs.chain(([{ nodes }]) => setAttribute(nodes)),
240+
testDocs.chain(([{ nodes }]) => setAttributes(nodes)),
241241
(edit) => {
242242
editor.dispatchEvent(newEditEventV2(edit));
243243
return (
244244
Object.entries(edit.attributes)
245245
.filter(([name]) => xmlAttributeName.test(name))
246246
.map((entry) => entry as [string, string | null])
247247
.every(
248-
([name, value]) => edit.element.getAttribute(name) === value
248+
([name, value]) => edit.element.getAttribute(name) === value,
249249
) &&
250250
Object.entries(edit.attributesNS)
251251
.map(
252-
(entry) => entry as [string, Record<string, string | null>]
252+
(entry) => entry as [string, Record<string, string | null>],
253253
)
254254
.every(([ns, attributes]) =>
255255
Object.entries(attributes)
@@ -261,13 +261,13 @@ describe("Utility function to handle EditV2 edits", () => {
261261
ns,
262262
name.includes(":")
263263
? <string>name.split(":", 2)[1]
264-
: name
265-
) === value
266-
)
264+
: name,
265+
) === value,
266+
),
267267
)
268268
);
269-
}
270-
)
269+
},
270+
),
271271
)).timeout(20000);
272272

273273
it("removes elements on Remove edit events", () =>
@@ -277,8 +277,8 @@ describe("Utility function to handle EditV2 edits", () => {
277277
({ node }) => {
278278
editor.dispatchEvent(newEditEventV2({ node }));
279279
return !node.parentNode;
280-
}
281-
)
280+
},
281+
),
282282
));
283283

284284
it("undoes up to n edits on undo(n) call", () =>
@@ -287,21 +287,21 @@ describe("Utility function to handle EditV2 edits", () => {
287287
testDocs.chain((docs) => undoRedoTestCases(...docs)),
288288
({ doc1, doc2, edits, squash }: UndoRedoTestCase) => {
289289
const [oldDoc1, oldDoc2] = [doc1, doc2].map((doc) =>
290-
doc.cloneNode(true)
290+
doc.cloneNode(true),
291291
);
292292
edits.forEach((a: EditV2) => {
293293
editor.dispatchEvent(newEditEventV2(a, { squash }));
294294
});
295295
if (editor.editCount) editor.undo(editor.editCount);
296296
expect(doc1).to.satisfy((doc: XMLDocument) =>
297-
doc.isEqualNode(oldDoc1)
297+
doc.isEqualNode(oldDoc1),
298298
);
299299
expect(doc2).to.satisfy((doc: XMLDocument) =>
300-
doc.isEqualNode(oldDoc2)
300+
doc.isEqualNode(oldDoc2),
301301
);
302302
return true;
303-
}
304-
)
303+
},
304+
),
305305
)).timeout(20000);
306306

307307
it("redoes up to n edits on redo(n) call", () =>
@@ -313,19 +313,19 @@ describe("Utility function to handle EditV2 edits", () => {
313313
editor.dispatchEvent(newEditEventV2(a));
314314
});
315315
const [oldDoc1, oldDoc2] = [doc1, doc2].map((doc) =>
316-
new XMLSerializer().serializeToString(doc)
316+
new XMLSerializer().serializeToString(doc),
317317
);
318318

319319
if (edits.length) {
320320
editor.undo(edits.length + 1);
321321
editor.redo(edits.length + 1);
322322
}
323323
const [newDoc1, newDoc2] = [doc1, doc2].map((doc) =>
324-
new XMLSerializer().serializeToString(doc)
324+
new XMLSerializer().serializeToString(doc),
325325
);
326326
return oldDoc1 === newDoc1 && oldDoc2 === newDoc2;
327-
}
328-
)
327+
},
328+
),
329329
)).timeout(20000);
330330
});
331331
});

Editor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { state } from "lit/decorators.js";
33

44
import { EditEventV2 } from "./edit-event.js";
55

6-
import { EditV2, handleEdit } from "./handleEdit.js";
6+
import { EditV2 } from "./editv2.js";
7+
8+
import { handleEdit } from "./handleEdit.js";
79

810
export type LogEntry = {
911
undo: EditV2;
@@ -117,7 +119,7 @@ export class Editor extends LitElement {
117119
super();
118120

119121
this.addEventListener("oscd-edit-v2", (event) =>
120-
this.handleEditEvent(event)
122+
this.handleEditEvent(event),
121123
);
122124
}
123125
}

edit-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EditV2 } from "./handleEdit.js";
1+
import { EditV2 } from "./editv2.js";
22

33
export type EditDetailV2<E extends EditV2 = EditV2> = {
44
edit: E;

handleEdit.spec.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
isValidInsert,
77
remove,
88
sclDocString,
9-
setAttribute,
9+
setAttributes,
1010
setTextContent,
1111
testDocs,
1212
UndoRedoTestCase,
@@ -183,37 +183,37 @@ describe("handleEdit", () => {
183183
it("updates attributes given SetAttributes", () =>
184184
assert(
185185
property(
186-
testDocs.chain(([{ nodes }]) => setAttribute(nodes)),
186+
testDocs.chain(([{ nodes }]) => setAttributes(nodes)),
187187
(edit) => {
188188
handleEdit(edit);
189-
return (
190-
Object.entries(edit.attributes)
191-
.filter(([name]) => xmlAttributeName.test(name))
192-
.map((entry) => entry as [string, string | null])
193-
.every(
194-
([name, value]) => edit.element.getAttribute(name) === value,
195-
) &&
196-
Object.entries(edit.attributesNS)
197-
.map(
198-
(entry) => entry as [string, Record<string, string | null>],
199-
)
200-
.every(([ns, attributes]) =>
201-
Object.entries(attributes)
202-
.filter(([name]) => xmlAttributeName.test(name))
203-
.map((entry) => entry as [string, string | null])
204-
.every(
205-
([name, value]) =>
206-
edit.element.getAttributeNS(
207-
ns,
208-
name.includes(":")
209-
? <string>name.split(":", 2)[1]
210-
: name,
211-
) === value,
212-
),
213-
)
214-
);
189+
const attributesHandledCorrectly = Object.entries(edit.attributes)
190+
.filter(([name]) => xmlAttributeName.test(name))
191+
.map((entry) => entry as [string, string | null])
192+
.every(
193+
([name, value]) => edit.element.getAttribute(name) === value,
194+
);
195+
const attributesNSHandledCorrectly = Object.entries(
196+
edit.attributesNS,
197+
)
198+
.map((entry) => entry as [string, Record<string, string | null>])
199+
.every(([ns, attributes]) =>
200+
Object.entries(attributes)
201+
.filter(([name]) => xmlAttributeName.test(name))
202+
.map((entry) => entry as [string, string | null])
203+
.every(
204+
([name, value]) =>
205+
edit.element.getAttributeNS(
206+
ns,
207+
name.includes(":")
208+
? <string>name.split(":", 2)[1]
209+
: name,
210+
) === value,
211+
),
212+
);
213+
return attributesHandledCorrectly && attributesNSHandledCorrectly;
215214
},
216215
),
216+
{ seed: 847773831 },
217217
)).timeout(20000);
218218

219219
it("removes elements given Removes", () =>

handleEdit.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ function handleSetAttributes({
132132

133133
function handleRemove({ node }: Remove): Insert | [] {
134134
const { parentNode: parent, nextSibling: reference } = node;
135+
136+
if (!parent) return [];
137+
135138
node.parentNode?.removeChild(node);
136-
if (parent)
137-
return {
138-
node,
139-
parent,
140-
reference,
141-
};
142-
return [];
139+
return {
140+
node,
141+
parent,
142+
reference,
143+
};
143144
}
144145

145146
function handleInsert({

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {
2222
complexEdit,
2323
edit,
2424
remove,
25-
setAttribute,
25+
setAttributes,
2626
setTextContent,
2727
simpleEdit,
2828
} from "./testHelpers.js";

0 commit comments

Comments
 (0)