From 86b893a3641a520aa4b01024d8c965609b89883c Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Wed, 11 Mar 2026 02:27:34 -0400 Subject: [PATCH] test(session): add comprehensive tests for session behavior and caching Signed-off-by: Okiki Ojo --- session_test.ts | 397 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 397 insertions(+) create mode 100644 session_test.ts diff --git a/session_test.ts b/session_test.ts new file mode 100644 index 0000000..05bee3e --- /dev/null +++ b/session_test.ts @@ -0,0 +1,397 @@ +/** + * Tests for session.ts. + */ +// deno-lint-ignore-file no-import-prefix no-unversioned-import +import { describe, it } from 'jsr:@std/testing/bdd'; +import { expect } from 'jsr:@std/expect'; +import * as fc from 'npm:fast-check'; + +import { + odd_character_wikitext_string, + pathological_wikitext_string, + spacing_heavy_wikitext_string, + wikiish_string, +} from './_test_utils/arbitraries.ts'; +import { UNICODE_TEXT_FIXTURES } from './_test_utils/unicode_fixtures.ts'; +import { DiagnosticCode } from './events.ts'; +import { createSession } from './session.ts'; +import { events, outlineEvents, parse, parseWithDiagnostics, parseWithRecovery } from './parse.ts'; +import type { TextSource } from './text_source.ts'; + +const SESSION_FIXTURES = [ + [ + '== Lead ==', + `A [[Main Page|home]] link with ''italic'' and '''bold'''.`, + '', + '* Bullet one', + '* Bullet two with {{Card|title=Plan|body=value}}', + '', + '{|', + '! Planet !! Notes', + '|-', + '| Mars || Known as the red planet', + '|}', + ].join('\n'), + [ + 'Paragraph with [[literal]] text and & entity.', + 'Second line keeps the paragraph open until a blank line.', + '', + '; Term', + ': Description with [https://example.com label]', + ].join('\n'), + [ + '[[[[{{{{