Skip to content

Commit

Permalink
🧪 test: pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Apr 18, 2024
1 parent 99a61c5 commit f6c9d82
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/chili-core/test/node.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license.

import { History, IDocument, INode, NodeLinkedList } from "../src";
import { IDocument, INode, NodeLinkedList } from "../src";
import { TestDocument } from "./testDocument";

describe("test node", () => {
let doc: IDocument = { history: new History() } as any;
let doc: IDocument = new TestDocument() as any;

test("test get all nodes between two nodes", () => {
let n1 = new NodeLinkedList(doc, "n1");
Expand Down
5 changes: 3 additions & 2 deletions packages/chili-core/test/nodeList.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license.

import { History, IDocument, NodeLinkedList } from "../src";
import { IDocument, NodeLinkedList } from "../src";
import { TestDocument } from "./testDocument";

describe("test NodeLinkedList", () => {
let doc: IDocument = { history: new History() } as any;
let doc: IDocument = new TestDocument() as any;

test("test add and remove", () => {
let l1 = new NodeLinkedList(doc, "l1");
Expand Down
4 changes: 3 additions & 1 deletion packages/chili-core/test/serializer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license.

import { History, IDocument, NodeLinkedList, NodeSerializer, Serialized, Serializer } from "../src";
import { TestDocument } from "./testDocument";

@Serializer.register("BoxBody", ["k1" as any])
class TestObject {
Expand Down Expand Up @@ -38,7 +39,8 @@ test("test Serializer", () => {
});

test("test Node Serializer", () => {
let doc: IDocument = { history: new History() } as any;
let doc: IDocument = new TestDocument() as any;

let n1 = new NodeLinkedList(doc, "n1");
let n2 = new NodeLinkedList(doc, "n2");
let n3 = new NodeLinkedList(doc, "n3");
Expand Down
11 changes: 11 additions & 0 deletions packages/chili-core/test/testDocument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license.

import { History, INodeChangedObserver, NodeLinkedListHistoryRecord, NodeRecord, Transaction } from "../src";

export class TestDocument {
history = new History();
notifyNodeChanged(records: NodeRecord[]) {
Transaction.add(this, this.history, new NodeLinkedListHistoryRecord(records));
}
addNodeObserver(observer: INodeChangedObserver) {}
}
4 changes: 1 addition & 3 deletions packages/chili-three/test/testDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export class TestDocument implements IDocument, ISerialize {
this.rootNode = {} as any;
this.application = { views: [] } as any;
}
addNodeObserver(observer: INodeChangedObserver): void {
throw new Error("Method not implemented.");
}
addNodeObserver(observer: INodeChangedObserver): void {}
removeNodeObserver(observer: INodeChangedObserver): void {
throw new Error("Method not implemented.");
}
Expand Down

0 comments on commit f6c9d82

Please sign in to comment.