2024-02-09 04:00:45 +08:00
|
|
|
import { assertEquals } from "$lib/test_deps.ts";
|
2023-10-03 20:16:33 +08:00
|
|
|
import { extractSnippet } from "./page_links.ts";
|
|
|
|
|
|
|
|
Deno.test("Snippet extraction", () => {
|
|
|
|
const sample1 = `This is a test
|
|
|
|
and a [[new]] line that runs super duper duper duper duper duper long
|
|
|
|
[[SETTINGS]]
|
|
|
|
super`;
|
|
|
|
assertEquals(
|
|
|
|
extractSnippet(sample1, sample1.indexOf("[[new]]")),
|
|
|
|
"and a [[new]] line that runs sup",
|
|
|
|
);
|
|
|
|
assertEquals(
|
|
|
|
extractSnippet(sample1, sample1.indexOf("[[SETTINGS]]")),
|
|
|
|
"[[SETTINGS]]",
|
|
|
|
);
|
|
|
|
});
|