Skip to content

Commit

Permalink
chore: update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bachbui committed Nov 13, 2024
1 parent 1ab13e8 commit 0f0c6a3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/@atjson/util/test/extract-slices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,29 @@ describe("extractSlices", () => {
refs: ["B00000000"],
},
},
{
id: "M00000003",
type: "italic",
range: "(6..7]",
},
],
};
let [doc, slices] = extractSlices(original);
expect(slices.get("M00000000")?.text).toEqual("AAA");
expect(slices.get("M00000001")?.text).toEqual("B");
expect(slices.get("M00000002")?.text).toEqual("C");
expect(doc.text).toEqual("D");
expect(doc.marks).toMatchInlineSnapshot(`
[
{
"end": 2,
"id": "M00000003",
"range": "(1..2]",
"start": 1,
"type": "italic",
},
]
`);
});

test("start slice position matches", () => {
Expand Down Expand Up @@ -542,13 +558,29 @@ describe("extractSlices", () => {
refs: ["B00000000"],
},
},
{
id: "M00000003",
type: "italic",
range: "(5..6]",
},
],
};
let [doc, slices] = extractSlices(original);
expect(slices.get("M00000000")?.text).toEqual("A");
expect(slices.get("M00000001")?.text).toEqual("BB");
expect(slices.get("M00000002")?.text).toEqual("C");
expect(doc.text).toEqual("D");
expect(doc.marks).toMatchInlineSnapshot(`
[
{
"end": 2,
"id": "M00000003",
"range": "(1..2]",
"start": 1,
"type": "italic",
},
]
`);
});

test("hanging overlapping slices", () => {
Expand Down Expand Up @@ -580,12 +612,28 @@ describe("extractSlices", () => {
refs: ["B00000000"],
},
},
{
id: "M00000002",
type: "italic",
range: "(4..5]",
},
],
};
let [doc, slices] = extractSlices(original);
expect(slices.get("M00000000")?.text).toEqual("AB");
expect(slices.get("M00000001")?.text).toEqual("BC");
expect(doc.text).toEqual("D");
expect(doc.marks).toMatchInlineSnapshot(`
[
{
"end": 2,
"id": "M00000002",
"range": "(1..2]",
"start": 1,
"type": "italic",
},
]
`);
});

describe("retain", () => {
Expand Down

0 comments on commit 0f0c6a3

Please sign in to comment.