<commit_before>import { doesNotReject, ok, rejects, strictEqual } from "assert";
import { Server } from "http";
import { TempDirectory, TempFile } from "@manuth/temp-files";
import { pathExists, remove, writeFile } from "fs-extra";
import MarkdownIt = require("markdown-it");
import { Browser, launch, Page } from "puppeteer-core";
import { changeExt } from "upath";
import { TextDocument, workspace } from "vscode";
import { ConversionType } from "../../../Conversion/ConversionType";
import { Converter } from "../../../Conversion/Converter";
import { Document } from "../../../System/Documents/Document";

/**
 * Registers tests for the `Converter` class.
 */
export function ConverterTests(): void
{
    suite(
        "Converter",
        () =>
        {
            let converter: TestConverter;
            let initializedConverter: TestConverter;
            let document: Document;
            let tempDir: TempDirectory;
            let tempFile: TempFile;
            let outFile: TempFile;
            let textDocument: TextDocument;

            /**
             * Provides an implementation of the `Converter` class for testing.
             */
            class TestConverter extends Converter
            {
                /**
                 * @inheritdoc
                 */
                public get WebServer(): Server
                {
                    return super.WebServer;
                }

                /**
                 * @inheritdoc
                 */
                public get Browser(): Browser
                {
                    return super.Browser;
                }
            }

            suiteSetup(
                async () =>
                {
                    let parser = new MarkdownIt();
                    tempDir = new TempDirectory();

                    tempFile = new TempFile(
                        {
                            Directory: tempDir.FullName,
                            Suffix: ".md"
                        });

                    outFile = new TempFile(
                        {
                            Directory: tempDir.FullName,
                            Suffix: ".tmp"
                        });

                    await writeFile(tempFile.FullName, "This is a test");
                    textDocument = await workspace.openTextDocument(tempFile.FullName);
                    document = new Document(textDocument, parser);
                });

            suiteTeardown(
                () =>
                {
                    tempFile.Dispose();
                    outFile.Dispose();
                    tempDir.Dispose();
                });

            setup(
                async () =>
                {
                    converter = new TestConverter(tempDir.FullName, document);
                    initializedConverter = new TestConverter(tempDir.FullName, document);
                    await initializedConverter.Initialize();
                });

            suite(
                "constructor",
                () =>
                {
                    test(
                        "Checking whether the properties are set correctly…",
                        () =>
                        {
                            converter = new TestConverter(tempDir.FullName, document);
                            strictEqual(converter.WorkspaceRoot, tempDir.FullName);
                            strictEqual(converter.Document, document);
                        });
                });

            suite(
                "Initialized",
                () =>
                {
                    test(
                        "Checking whether the value is initially `false`…",
                        () =>
                        {
                            ok(!converter.Initialized);
                        });

                    test(<commit_msg>Refactor the tests for the `Converter` class<commit_after>import { doesNotReject, ok, rejects, strictEqual } from "assert";
import { Server } from "http";
import { TempDirectory, TempFile } from "@manuth/temp-files";
import { pathExists, remove, writeFile } from "fs-extra";
import MarkdownIt = require("markdown-it");
import { Browser, launch, Page } from "puppeteer-core";
import { changeExt } from "upath";
import { TextDocument, workspace } from "vscode";
import { ConversionType } from "../../../Conversion/ConversionType";
import { Converter } from "../../../Conversion/Converter";
import { Document } from "../../../System/Documents/Document";

/**
 * Registers tests for the `Converter` class.
 */
export function ConverterTests(): void
{
    suite(
        "Converter",
        () =>
        {
            let converter: TestConverter;
            let initializedConverter: TestConverter;
            let document: Document;
            let tempDir: TempDirectory;
            let tempFile: TempFile;
            let outFile: TempFile;
            let textDocument: TextDocument;

            /**
             * Provides an implementation of the `Converter` class for testing.
             */
            class TestConverter extends Converter
            {
                /**
                 * @inheritdoc
                 */
                public get WebServer(): Server
                {
                    return super.WebServer;
                }

                /**
                 * @inheritdoc
                 */
                public get Browser(): Browser
                {
                    return super.Browser;
                }
            }

            suiteSetup(
                async () =>
                {
                    let parser = new MarkdownIt();
                    tempDir = new TempDirectory();

                    tempFile = new TempFile(
                        {
                            Directory: tempDir.FullName,
                            Suffix: ".md"
                        });

                    outFile = new TempFile(
                        {
                            Directory: tempDir.FullName,
                            Suffix: ".tmp"
                        });

                    await writeFile(tempFile.FullName, "This is a test");
                    textDocument = await workspace.openTextDocument(tempFile.FullName);
                    document = new Document(textDocument, parser);
                });

            suiteTeardown(
                () =>
                {
                    tempFile.Dispose();
                    outFile.Dispose();
                    tempDir.Dispose();
                });

            setup(
                async () =>
                {
                    converter = new TestConverter(tempDir.FullName, document);
                    initializedConverter = new TestConverter(tempDir.FullName, document);
                    await initializedConverter.Initialize();
                });

            suite(
                "constructor",
                () =>
                {
                    test(
                        "Checking whether the properties are set correctly…",
                        () =>
                        {
                            converter = new TestConverter(tempDir.FullName, document);
                            strictEqual(converter.DocumentRoot, tempDir.FullName);
                            strictEqual(converter.Document, document);
                        });
                });

            suite(
                "Initialized",
                () =>
                {
                    test(
                        "Checking whether the value is initially `false`…",
                        () =>
                        {
                            ok(!converter.Initialized);
                        });

                    test(
{'fraction_non_alphanumeric': 0.09228402973596514, 'fraction_numerical': 0.0, 'mean_word_length': 1.0220264317180616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193266', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1587, 'n_words': 393}