From 4d3fcb51ecd02990698bae4abf03ec21656210db Mon Sep 17 00:00:00 2001 From: nimratcoderabbit Date: Tue, 15 Jul 2025 12:55:00 -0400 Subject: [PATCH] Language tool files --- languageTool.test.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++ sample.txt | 10 +++++++++ 2 files changed, 62 insertions(+) create mode 100644 languageTool.test.ts create mode 100644 sample.txt diff --git a/languageTool.test.ts b/languageTool.test.ts new file mode 100644 index 0000000..695d191 --- /dev/null +++ b/languageTool.test.ts @@ -0,0 +1,52 @@ +import { runLanguageTool } from "./languageTool" +import fs from "fs" +import { env } from "../../utils/env" + +const fileContent = fs.readFileSync("sample.txt", "utf-8") + +const mockParams = { + logger: { + child: () => ({ + debug: console.log, + error: console.error, + }), + }, + settings: { + configSettings: { + reviews: { + profile: "chill", // or "assertive" + tools: { + languagetool: { + enabled: true, + disabled_categories: [], + disabled_rules: [], + enabled_categories: [], + enabled_rules: [], + enabled_only: false, + level: "default", + }, + }, + }, + language: "en-US", + }, + }, + fileHunks: [ + { + repoFile: { + filename: "sample.txt", + }, + fileContent, + hunks: [], + toolOutputs: {}, + }, + ], +} as any + +// Fake credentials for testing (you should replace these with valid test creds or mock the API) +env.LANGUAGETOOL_USERNAME = "fakeUser" +env.LANGUAGETOOL_API_KEY = "fakeKey" + +runLanguageTool(mockParams).then(() => { + console.log("Test complete. Tool outputs:", mockParams.fileHunks[0].toolOutputs) +}) + diff --git a/sample.txt b/sample.txt new file mode 100644 index 0000000..99e5bd9 --- /dev/null +++ b/sample.txt @@ -0,0 +1,10 @@ +This is a test file with some intentional errors. + +Their going to the park later, maybe I'll join to. +This sentence have a agreement error. +The list are long and detailed. +He don't know what he doing. +Here is a mispeling. + +It is an very good idea to try this tool, isn't it. +