From 37df46381ba4163d6e15e985062df9bcd336a325 Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Sun, 6 Aug 2023 23:10:12 -0400 Subject: [PATCH] Make the existing visual test a snapshot unit test. --- src/__snapshots__/notcl.test.ts.snap | 164 +++++++++++++++++++++++++++ src/notcl.test.ts | 49 ++++++++ 2 files changed, 213 insertions(+) create mode 100644 src/__snapshots__/notcl.test.ts.snap diff --git a/src/__snapshots__/notcl.test.ts.snap b/src/__snapshots__/notcl.test.ts.snap new file mode 100644 index 0000000..d26de58 --- /dev/null +++ b/src/__snapshots__/notcl.test.ts.snap @@ -0,0 +1,164 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Parsing Notcl Misc Big mess of markup 1`] = ` +[ + true, + [ + [ + { + "text": "h1", + }, + { + "text": ""Hello,", + }, + { + "text": "World!"", + }, + ], + [ + { + "text": "para", + }, + { + "text": "[2", + }, + { + "text": "+", + }, + { + "text": "2]", + }, + ], + [ + { + "text": "block", + }, + { + "text": " + This is a paragraph of text, with one [b bold] word. Yes, this means there has to be some magic in text processing... this won't work. + ", + }, + ], + [ + { + "text": "block", + }, + { + "text": "-red", + }, + { + "text": ""Beware!"", + }, + ], + [ + { + "text": "para", + }, + { + "text": ""All", + }, + { + "text": "text", + }, + { + "text": "should", + }, + { + "text": "be", + }, + { + "text": "quoted,", + }, + { + "text": "it's", + }, + { + "text": "clearer", + }, + { + "text": "that", + }, + { + "text": "way.", + }, + { + "text": "&", + }, + { + "text": "blockquotes", + }, + { + "text": "already", + }, + { + "text": "should", + }, + { + "text": "contain", + }, + { + "text": "paragraphs.", + }, + { + "text": "(maybe", + }, + { + "text": "normalize", + }, + { + "text": "nested", + }, + { + "text": "paragraphs)"", + }, + ], + [ + { + "text": "block", + }, + { + "text": " + First block + ", + }, + { + "text": " + Second block + + Is this markdown-parsed? + + [button "No we want to render UI" \\\\{noop}] + ", + }, + { + "text": " + Since we want escapes to work, these blocks [i will] be subject to substitutions. + ", + }, + ], + [ + { + "text": "para", + }, + { + "text": " + line endings escaped one slash + + not escaped if \\\\ + two slashes + + escaped with a slash if \\\\ three slashes + + not escaped with two slashes if \\\\\\\\ + four slashes + + escaped with two slashes if \\\\\\\\ five slashes + + not escaped with three slashes if \\\\\\\\\\\\ + six slashes + ", + }, + ], + ], +] +`; diff --git a/src/notcl.test.ts b/src/notcl.test.ts index b39cbfa..23007dc 100644 --- a/src/notcl.test.ts +++ b/src/notcl.test.ts @@ -88,12 +88,61 @@ b`) // nesting // escapes // {, }, correct newline folding + // no trailing chars // "Quotes" + // no trailing chars // Interpolated words // bare // quotes // variables- bare, brace // command subst + + describe("Misc", () => { + test("Big mess of markup", () => { + expect( + parse(String.raw` + h1 "Hello, World!" + para [2 + 2] + block { + This is a paragraph of text, with one [b bold] word. Yes, this means there has to be some magic in text processing... this won't work. + } + block -red "Beware!" + para "All text should be quoted, it's clearer that way. & blockquotes already should contain paragraphs. (maybe normalize nested paragraphs)" + block { + First block + } { + Second block + + Is this markdown-parsed? + + [button "No we want to render UI" \\{noop}] + } { + Since we want escapes to work, these blocks [i will] be subject to substitutions. + } + # A comment + para { + line endings escaped\ + one slash + + not escaped if \\ + two slashes + + escaped with a slash if \\\ + three slashes + + not escaped with two slashes if \\\\ + four slashes + + escaped with two slashes if \\\\\ + five slashes + + not escaped with three slashes if \\\\\\ + six slashes + } + `) + ).toMatchSnapshot(); + }); + }); });