Skip to content

Commit aeb107f

Browse files
committed
tests: frontend tests
1 parent 6f4c9bb commit aeb107f

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

frontend/src/core/codemirror/language/__tests__/extension.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,36 +163,30 @@ describe("switchLanguage", () => {
163163
// Switch back to python
164164
switchLanguage(mockEditor, { language: "python", keepCodeAsIs: false });
165165
expect(mockEditor.state.doc.toString()).toMatchInlineSnapshot(`
166-
"mo.md(
167-
r"""
166+
"mo.md(r"""
168167
print('Hello')
169168
print('Goodbye')
170-
"""
171-
)"
169+
""")"
172170
`);
173171

174172
// Switch to sql
175173
switchLanguage(mockEditor, { language: "sql", keepCodeAsIs: false });
176174
expect(mockEditor.state.doc.toString()).toMatchInlineSnapshot(`
177-
"mo.md(
178-
r"""
175+
"mo.md(r"""
179176
print('Hello')
180177
print('Goodbye')
181-
"""
182-
)"
178+
""")"
183179
`);
184180

185181
// Switch back to python
186182
switchLanguage(mockEditor, { language: "python", keepCodeAsIs: false });
187183
expect(mockEditor.state.doc.toString()).toMatchInlineSnapshot(`
188184
"_df = mo.sql(
189185
f"""
190-
mo.md(
191-
r\\"""
186+
mo.md(r\\"""
192187
print('Hello')
193188
print('Goodbye')
194-
\\"""
195-
)
189+
\\""")
196190
"""
197191
)"
198192
`);

frontend/src/core/codemirror/language/__tests__/markdown.test.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe("MarkdownLanguageAdapter", () => {
186186

187187
it("should preserve indentation in f-strings", () => {
188188
const pythonCode =
189-
'mo.md(\n f"""\n```python\n{some_variable}\n```\n"""\n)';
189+
'mo.md(f"""\n```python\n{some_variable}\n```\n""")';
190190
const [innerCode, offset, metadata] = adapter.transformIn(pythonCode);
191191
expect(innerCode).toBe("```python\n{some_variable}\n```");
192192
expect(offset).toBe(15);
@@ -312,12 +312,10 @@ describe("MarkdownLanguageAdapter", () => {
312312
metadata.quotePrefix = "f";
313313
const [wrappedCode, offset] = adapter.transformOut(code, metadata);
314314
expect(wrappedCode).toMatchInlineSnapshot(`
315-
"mo.md(
316-
f"""
315+
"mo.md(f"""
317316
# Title
318317
{some_variable}
319-
"""
320-
)"
318+
""")"
321319
`);
322320
expect(offset).toBe(17);
323321
});
@@ -327,12 +325,10 @@ describe("MarkdownLanguageAdapter", () => {
327325
metadata.quotePrefix = "rf";
328326
const [wrappedCode, offset] = adapter.transformOut(code, metadata);
329327
expect(wrappedCode).toMatchInlineSnapshot(`
330-
"mo.md(
331-
rf"""
328+
"mo.md(rf"""
332329
# Title
333330
{some_variable}
334-
"""
335-
)"
331+
""")"
336332
`);
337333
expect(offset).toBe(18);
338334
});
@@ -369,13 +365,11 @@ describe("MarkdownLanguageAdapter", () => {
369365

370366
it("should return true for complex nested markdown", () => {
371367
const pythonCode = String.raw`
372-
mo.md(
373-
rf"""
374-
\`\`\`python
375-
{pathlib.Path(__file__).read_text(encoding="utf-8")}
376-
\`\`\`
377-
"""
378-
)
368+
mo.md(rf"""
369+
\`\`\`python
370+
{pathlib.Path(__file__).read_text(encoding="utf-8")}
371+
\`\`\`
372+
""")
379373
`;
380374
expect(adapter.isSupported(pythonCode)).toBe(true);
381375
});

0 commit comments

Comments
 (0)