diff --git a/tests/UnconnectedElement.test.ts b/tests/UnconnectedElement.test.ts index c9e82b8..f2297fe 100644 --- a/tests/UnconnectedElement.test.ts +++ b/tests/UnconnectedElement.test.ts @@ -40,4 +40,25 @@ describe("UnconnectedElement", () => { expect(ruleDetail.name).to.equal("UnconnectedElementTestOnAsync"); }); }); + + it("should fix the unconnected element error", async () => { + const connectedElementTestFile = path.join( + __dirname, + "./xmlfiles/Unconnected_Element.flow-meta.xml" + ); + let flows = await core.parse([connectedElementTestFile]); + const ruleConfig = { + rules: { + UnconnectedElement: { + severity: "error", + }, + }, + }; + const results: core.ScanResult[] = core.scan(flows, ruleConfig); + const fixedResults: core.ScanResult[] = core.fix(results); + const fixedFlow: ParsedFlow = new ParsedFlow(connectedElementTestFile, fixedResults[0].flow); + const newResults: core.ScanResult[] = core.scan([fixedFlow], ruleConfig); + const fixedResultsOccurring = newResults[0].ruleResults.filter((rule) => rule.occurs); + expect(fixedResultsOccurring.length).to.equal(0); + }); }); diff --git a/tests/UnusedVariable.test.ts b/tests/UnusedVariable.test.ts index f2889fd..6b20805 100644 --- a/tests/UnusedVariable.test.ts +++ b/tests/UnusedVariable.test.ts @@ -1,6 +1,7 @@ import "mocha"; import * as core from "../src"; import * as path from "path-browserify"; +import { ParsedFlow } from "../src/main/models/ParsedFlow"; describe("UnusedVariable Rule", () => { let expect; @@ -38,4 +39,21 @@ describe("UnusedVariable Rule", () => { const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs); expect(occurringResults.length).to.equal(0); }); + + it("should fix the unused variable error", async () => { + let flows = await core.parse([example_uri]); + const ruleConfig = { + rules: { + UnusedVariable: { + severity: "error", + }, + }, + }; + const results: core.ScanResult[] = core.scan(flows, ruleConfig); + const fixedResults: core.ScanResult[] = core.fix(results); + const fixedFlow: ParsedFlow = new ParsedFlow(example_uri, fixedResults[0].flow); + const newResults: core.ScanResult[] = core.scan([fixedFlow], ruleConfig); + const fixedResultsOccurring = newResults[0].ruleResults.filter((rule) => rule.occurs); + expect(fixedResultsOccurring.length).to.equal(0); + }); });