From 61640f00396bf23a81cfa3907011520e89b167e0 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Wed, 28 Feb 2024 10:33:17 -0700 Subject: [PATCH] regression test for convert --- tests/docs/convert/backticks.ipynb | 40 +++++++++++++++++++ tests/smoke/convert/convert-backticks.test.ts | 36 +++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 tests/docs/convert/backticks.ipynb create mode 100644 tests/smoke/convert/convert-backticks.test.ts diff --git a/tests/docs/convert/backticks.ipynb b/tests/docs/convert/backticks.ipynb new file mode 100644 index 0000000000..73e3bc8253 --- /dev/null +++ b/tests/docs/convert/backticks.ipynb @@ -0,0 +1,40 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "d02a6fa3", + "metadata": {}, + "outputs": [], + "source": [ + "message = \"\"\"\n", + "Content\n", + "```python\n", + "print(\"Hello, world!\")\n", + "```\n", + "\"\"\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/tests/smoke/convert/convert-backticks.test.ts b/tests/smoke/convert/convert-backticks.test.ts new file mode 100644 index 0000000000..e3081fccbf --- /dev/null +++ b/tests/smoke/convert/convert-backticks.test.ts @@ -0,0 +1,36 @@ +/* +* convert-backticks.test.ts +* +* Copyright (C) 2020-2024 Posit Software, PBC +* +*/ +import { existsSync } from "../../../src/deno_ral/fs.ts"; +import { + ExecuteOutput, + testQuartoCmd, +} from "../../test.ts"; +import { assert } from "testing/asserts.ts"; + +(() => { + const input = "docs/convert/backticks.ipynb"; + testQuartoCmd( + "convert", + ["docs/convert/backticks.ipynb"], + [ + { + name: "convert-enough-backticks", + verify: async (outputs: ExecuteOutput[]) => { + const txt = Deno.readTextFileSync("docs/convert/backticks.qmd"); + assert(txt.includes("````"), "Not enough backticks in output"); + } + } + ], + { + teardown: async () => { + if (existsSync("docs/convert/backticks.qmd")) { + Deno.removeSync("docs/convert/backticks.qmd"); + } + } + }, + ); +})();