Skip to content

Commit d9735de

Browse files
authored
test: fix deno codeblocks tests (#22)
1 parent c00665a commit d9735de

13 files changed

Lines changed: 190 additions & 41 deletions

File tree

deno_scripts/deno.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"nodeModulesDir": "auto",
33
"tasks": {
44
"check": "deno run -A ./run_code_blocks.ts"
5+
},
6+
"imports": {
7+
"expect": "npm:expect@^30.0.5"
58
}
69
}

deno_scripts/deno.lock

Lines changed: 166 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno_scripts/extract_code_blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface CodeBlock {
1111

1212
export function extractCodeBlocks(fileContent: string, codeBlocks: CodeBlock[], name: string, path: string) {
1313
// Regular expression to detect TypeScript code blocks
14-
const codeBlockRegex = /```(typescript|ts|js|javascript)\n([\s\S]*?)\n```/g;
14+
const codeBlockRegex = /```(typescript|ts twoslash|typescript twoslash|ts|js|javascript)\n([\s\S]*?)\n```/g;
1515
let match;
1616
while ((match = codeBlockRegex.exec(fileContent)) !== null) {
1717
const startLine = fileContent.substring(0, match.index).split("\n").length;

pages/docs/advanced/undo.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ undo/redo loop state.
114114

115115
```ts twoslash
116116
import { LoroDoc, UndoManager, Cursor } from "loro-crdt";
117-
const expect: any = () => {};
117+
import { expect } from "expect";
118118
// ---cut---
119119
const doc = new LoroDoc();
120120
let cursors: Cursor[] = [];

pages/docs/advanced/version_deep_dive.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ example:
209209

210210
```ts twoslash
211211
import { LoroDoc } from "loro-crdt";
212-
const expect: any = () => {};
212+
import { expect } from "expect";
213213
// ---cut---
214214
const doc = new LoroDoc();
215215
doc.setPeerId(0n);

pages/docs/tutorial/composition.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ By leveraging these fundamental CRDTs, you can effectively model the states and
1313

1414
```ts twoslash
1515
import { LoroDoc, LoroList, LoroText } from "loro-crdt";
16-
const expect: any = () => {};
16+
import { expect } from "expect";
1717
// ---cut---
1818
const doc = new LoroDoc();
1919
const map = doc.getMap("map");

pages/docs/tutorial/counter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Here is how to use it:
1111

1212
```ts twoslash
1313
import { LoroDoc } from "loro-crdt";
14-
const expect: any = () => {};
14+
import { expect } from "expect";
1515
// ---cut---
1616
const doc = new LoroDoc();
1717
const counter = doc.getCounter("counter");

pages/docs/tutorial/cursor.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Note: In JavaScript, the offset returned when querying a Stable Position is base
2323

2424
```ts twoslash
2525
import { LoroDoc } from "loro-crdt";
26-
const expect: any = () => {};
26+
import { expect } from "expect";
2727
// ---cut---
2828
const loro = new LoroDoc();
2929
const list = loro.getList("list");

0 commit comments

Comments
 (0)