Skip to content

Commit c871a81

Browse files
committed
test: update tests to fix lint issues
1 parent 9579a86 commit c871a81

17 files changed

+158
-158
lines changed

packages/core/src/core/loroEventApply.test.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ describe("applyEventBatchToState (inline)", () => {
4242

4343
const l = doc.getList("l");
4444
l.insert(0, "x");
45-
await commitAndAssert(doc, () => state);
45+
commitAndAssert(doc, () => state);
4646

4747
l.insert(1, "y");
48-
await commitAndAssert(doc, () => state);
48+
commitAndAssert(doc, () => state);
4949

5050
l.delete(0, 1);
51-
await commitAndAssert(doc, () => state);
51+
commitAndAssert(doc, () => state);
5252

5353
unsub();
5454
});
@@ -64,10 +64,10 @@ describe("applyEventBatchToState (inline)", () => {
6464

6565
const t = doc.getText("t");
6666
t.update("Hello");
67-
await commitAndAssert(doc, () => state);
67+
commitAndAssert(doc, () => state);
6868

6969
t.update("Hello World");
70-
await commitAndAssert(doc, () => state);
70+
commitAndAssert(doc, () => state);
7171

7272
unsub();
7373
});
@@ -85,10 +85,10 @@ describe("applyEventBatchToState (inline)", () => {
8585
const inner = new LoroText();
8686
inner.update("Hi");
8787
m.setContainer("inner", inner);
88-
await commitAndAssert(doc, () => state);
88+
commitAndAssert(doc, () => state);
8989

9090
inner.update("Hello");
91-
await commitAndAssert(doc, () => state);
91+
commitAndAssert(doc, () => state);
9292

9393
unsub();
9494
});
@@ -105,13 +105,13 @@ describe("applyEventBatchToState (inline)", () => {
105105
const m = doc.getMap("m");
106106
// Setting null should persist as a normal value
107107
m.set("a", null);
108-
await commitAndAssert(doc, () => state);
108+
commitAndAssert(doc, () => state);
109109

110110
// Setting a value then deleting it removes the key
111111
m.set("a", 42);
112-
await commitAndAssert(doc, () => state);
112+
commitAndAssert(doc, () => state);
113113
m.delete("a");
114-
await commitAndAssert(doc, () => state);
114+
commitAndAssert(doc, () => state);
115115

116116
unsub();
117117
});
@@ -128,13 +128,13 @@ describe("applyEventBatchToState (inline)", () => {
128128
const list = doc.getList("list");
129129
const text = list.insertContainer(0, new LoroText());
130130
text.update("Item 0");
131-
await commitAndAssert(doc, () => state);
131+
commitAndAssert(doc, () => state);
132132

133133
list.insert(1, "plain");
134-
await commitAndAssert(doc, () => state);
134+
commitAndAssert(doc, () => state);
135135

136136
text.update("Item 0 updated");
137-
await commitAndAssert(doc, () => state);
137+
commitAndAssert(doc, () => state);
138138

139139
unsub();
140140
});
@@ -152,10 +152,10 @@ describe("applyEventBatchToState (inline)", () => {
152152
ml.push("a");
153153
ml.push("b");
154154
ml.push("c");
155-
await commitAndAssert(doc, () => state);
155+
commitAndAssert(doc, () => state);
156156

157157
ml.move(0, 2); // [b, c, a]
158-
await commitAndAssert(doc, () => state);
158+
commitAndAssert(doc, () => state);
159159

160160
unsub();
161161
});
@@ -173,10 +173,10 @@ describe("applyEventBatchToState (inline)", () => {
173173
const list = rootMap.setContainer("list", new LoroList());
174174
const innerMap = list.insertContainer(0, new LoroMap());
175175
innerMap.set("k", 1);
176-
await commitAndAssert(doc, () => state);
176+
commitAndAssert(doc, () => state);
177177

178178
innerMap.set("k", 2);
179-
await commitAndAssert(doc, () => state);
179+
commitAndAssert(doc, () => state);
180180

181181
unsub();
182182
});
@@ -216,10 +216,10 @@ describe("applyEventBatchToState (inline)", () => {
216216

217217
const c = doc.getCounter("count");
218218
c.increment(5);
219-
await commitAndAssert(doc, () => state);
219+
commitAndAssert(doc, () => state);
220220

221221
c.decrement(2);
222-
await commitAndAssert(doc, () => state);
222+
commitAndAssert(doc, () => state);
223223

224224
unsub();
225225
});
@@ -239,11 +239,11 @@ describe("applyEventBatchToState (inline)", () => {
239239
const l = doc.getList("l");
240240
l.push(1);
241241
l.push(2);
242-
await commitAndAssert(doc, () => state);
242+
commitAndAssert(doc, () => state);
243243

244244
m.clear();
245245
l.clear();
246-
await commitAndAssert(doc, () => state);
246+
commitAndAssert(doc, () => state);
247247

248248
unsub();
249249
});
@@ -261,14 +261,14 @@ describe("applyEventBatchToState (inline)", () => {
261261
ml.push("x");
262262
ml.push("y");
263263
ml.push("z");
264-
await commitAndAssert(doc, () => state);
264+
commitAndAssert(doc, () => state);
265265

266266
// Replace middle with a container and delete last in one commit
267267
const t = new LoroText();
268268
t.update("middle");
269269
ml.setContainer(1, t);
270270
ml.delete(2, 1);
271-
await commitAndAssert(doc, () => state);
271+
commitAndAssert(doc, () => state);
272272

273273
unsub();
274274
});
@@ -288,11 +288,11 @@ describe("applyEventBatchToState (inline)", () => {
288288
const cnt2 = lst.insertContainer(0, new LoroCounter());
289289
cnt.increment(3);
290290
cnt2.increment(7);
291-
await commitAndAssert(doc, () => state);
291+
commitAndAssert(doc, () => state);
292292

293293
cnt.decrement(1);
294294
cnt2.decrement(2);
295-
await commitAndAssert(doc, () => state);
295+
commitAndAssert(doc, () => state);
296296

297297
unsub();
298298
});
@@ -311,11 +311,11 @@ describe("applyEventBatchToState (inline)", () => {
311311
const t1 = l.insertContainer(1, new LoroText());
312312
t0.update("A");
313313
t1.update("B");
314-
await commitAndAssert(doc, () => state);
314+
commitAndAssert(doc, () => state);
315315

316316
t0.update("AA");
317317
t1.update("BB");
318-
await commitAndAssert(doc, () => state);
318+
commitAndAssert(doc, () => state);
319319

320320
unsub();
321321
});
@@ -332,19 +332,19 @@ describe("applyEventBatchToState (inline)", () => {
332332
const t = doc.getText("t");
333333
t.insert(0, "Hello");
334334
t.splice(5, 0, " World");
335-
await commitAndAssert(doc, () => state);
335+
commitAndAssert(doc, () => state);
336336

337337
t.delete(0, 1); // remove 'H'
338-
await commitAndAssert(doc, () => state);
338+
commitAndAssert(doc, () => state);
339339

340340
t.applyDelta([{ retain: 0 }, { insert: "Start: " }]);
341-
await commitAndAssert(doc, () => state);
341+
commitAndAssert(doc, () => state);
342342

343343
// Mark/unmark shouldn't change string content
344344
doc.configTextStyle({ bold: { expand: "after" } });
345345
t.mark({ start: 0, end: 3 }, "bold", true);
346346
t.unmark({ start: 0, end: 3 }, "bold");
347-
await commitAndAssert(doc, () => state);
347+
commitAndAssert(doc, () => state);
348348

349349
unsub();
350350
});
@@ -386,7 +386,7 @@ describe("applyEventBatchToState (inline)", () => {
386386

387387
const m = doc.getMap("m");
388388
m.set("k", 1);
389-
await commitAndAssert(doc, () => state);
389+
commitAndAssert(doc, () => state);
390390

391391
// Setting the same value should not emit changes; state should remain in sync
392392
m.set("k", 1);
@@ -410,7 +410,7 @@ describe("applyEventBatchToState (inline)", () => {
410410
m.setContainer("k", txt);
411411
// Replace with primitive before commit
412412
m.set("k", "B");
413-
await commitAndAssert(doc, () => state);
413+
commitAndAssert(doc, () => state);
414414

415415
unsub();
416416
});
@@ -427,7 +427,7 @@ describe("applyEventBatchToState (inline)", () => {
427427
const txt = new LoroText();
428428
txt.update("C");
429429
m.setContainer("k", txt);
430-
await commitAndAssert(doc, () => state);
430+
commitAndAssert(doc, () => state);
431431

432432
unsub();
433433
});
@@ -444,7 +444,7 @@ describe("applyEventBatchToState (inline)", () => {
444444
t.update("x");
445445
l.insertContainer(0, t);
446446
l.delete(0, 1);
447-
await commitAndAssert(doc, () => state);
447+
commitAndAssert(doc, () => state);
448448

449449
unsub();
450450
});

packages/core/src/core/mirror.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export class Mirror<S extends SchemaType> {
437437
const newState = produce<InferType<S>>((draft) => {
438438
Object.assign(
439439
draft as unknown as Record<string, unknown>,
440-
(currentDocState ?? {}) as Record<string, unknown>,
440+
currentDocState,
441441
);
442442
})(this.state);
443443

packages/core/tests/cid.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
236236
const s = schema({ x: schema.LoroMap({ foo: schema.String() }) });
237237
const m = new Mirror({ doc, schema: s });
238238

239-
await m.setState((draft: any) => {
239+
m.setState((draft: any) => {
240240
draft.x.foo = "bar";
241241
draft.x[CID_KEY] = "user-defined";
242242
});
@@ -257,7 +257,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
257257
const before = JSON.stringify(doc.toJSON());
258258

259259
// Remove synthetic field from state; diffMap should ignore
260-
await m.setState((draft: any) => {
260+
m.setState((draft: any) => {
261261
delete draft.m[CID_KEY];
262262
});
263263
await Promise.resolve();
@@ -373,7 +373,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
373373
const second = m.getState().items[1];
374374

375375
// Swap order using $cid-based idSelector
376-
await m.setState({ items: [second, first] } as any);
376+
m.setState({ items: [second, first] } as any);
377377
await Promise.resolve();
378378

379379
const after = m.getState();
@@ -391,7 +391,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
391391
});
392392
const m = new Mirror({ doc, schema: s });
393393
// Create nested container via setState
394-
await m.setState({ root: { child: { name: "x" } } } as any);
394+
m.setState({ root: { child: { name: "x" } } } as any);
395395
const st = m.getState() as any;
396396
expect(st.root.child.name).toBe("x");
397397
expect(typeof st.root.child[CID_KEY]).toBe("string");
@@ -416,7 +416,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
416416
expect(cidBefore).toBe(attached.id);
417417

418418
// Replace existing child map by passing a plain object without $cid
419-
await m.setState({ root: { child: { name: "y" } } } as any);
419+
m.setState({ root: { child: { name: "y" } } } as any);
420420

421421
const after = m.getState() as any;
422422
expect(after.root.child.name).toBe("y");
@@ -441,7 +441,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
441441
expect(typeof prevCid).toBe("string");
442442

443443
// Update node data via setState, omitting $cid
444-
await m.setState({
444+
m.setState({
445445
tree: [
446446
{ id: before.tree[0].id, data: { title: "A*" }, children: [] },
447447
],
@@ -458,7 +458,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
458458
list: schema.LoroList(schema.LoroMap({ v: schema.Number() })),
459459
});
460460
const m = new Mirror({ doc, schema: s });
461-
await m.setState({ list: [{ v: 1 }, { v: 2 }] } as any);
461+
m.setState({ list: [{ v: 1 }, { v: 2 }] } as any);
462462
const st = m.getState() as any;
463463
expect(st.list).toHaveLength(2);
464464
expect(typeof st.list[0][CID_KEY]).toBe("string");
@@ -471,7 +471,7 @@ describe("$cid: state injection and write ignoring (always-on for LoroMap)", ()
471471
tree: schema.LoroTree(schema.LoroMap({ title: schema.String() })),
472472
});
473473
const m = new Mirror({ doc, schema: s });
474-
await m.setState({
474+
m.setState({
475475
tree: [
476476
{ id: "", data: { title: "A" }, children: [] },
477477
{ id: "", data: { title: "B" }, children: [] },

packages/core/tests/issue.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ it("Applying remote event then calling setState immediately may cause an event a
1616

1717
docB.getText("t").push(" ABC!");
1818
docA.import(docB.export({ mode: "update" }));
19-
await m.setState({ t: "" });
19+
m.setState({ t: "" });
2020
await Promise.resolve();
2121
expect(m.getState()).toStrictEqual(docA.toJSON());
2222
});
@@ -49,7 +49,7 @@ it("Reproduces 'Item ID cannot be null' when adding a new todo item using $cid-b
4949
// Calling setState should succeed and stamp $cid during apply,
5050
// but currently diffMovableList reads idSelector before $cid is assigned
5151
// and throws "Item ID cannot be null".
52-
await m.setState({
52+
m.setState({
5353
// Add a new item without $cid; $cid will only be stamped during apply
5454
todos: [{ text: "Buy milk", status: "todo" }],
5555
});

0 commit comments

Comments
 (0)