-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from alan-turing-institute/feature/74-sanitize…
…-markdown move jsonToMermaid from CaseContainer into utils, and add new functio…
- Loading branch information
Showing
6 changed files
with
258 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { render, screen, waitFor } from "@testing-library/react"; | ||
import "regenerator-runtime/runtime"; | ||
import React from "react"; | ||
import "@testing-library/jest-dom"; | ||
import { jsonToMermaid, sanitizeForMermaid } from "../utils.js"; | ||
|
||
test("Simple JSON translation", () => { | ||
let input = { | ||
id: 1, | ||
name: "Test case", | ||
description: "", | ||
goals: [ | ||
{ | ||
id: 1, | ||
name: "test goal", | ||
short_description: "short", | ||
long_description: "long", | ||
context: [], | ||
system_description: [], | ||
property_claims: [], | ||
}, | ||
], | ||
}; | ||
let output = jsonToMermaid(input); | ||
expect(output.includes("test goal")); | ||
}); | ||
|
||
test("Sanitize removes brackets, semicolon", () => { | ||
let input = "test (st;rin[g"; | ||
let output = sanitizeForMermaid(input); | ||
expect(output == "test string"); | ||
}); | ||
|
||
test("jsonToMermaid sanitizes goal name", () => { | ||
let input = { | ||
id: 1, | ||
name: "Test case", | ||
description: "", | ||
goals: [ | ||
{ | ||
id: 1, | ||
name: "test ()goal;}", | ||
short_description: "short", | ||
long_description: "long", | ||
context: [], | ||
system_description: [], | ||
property_claims: [], | ||
}, | ||
], | ||
}; | ||
let output = jsonToMermaid(input); | ||
expect(output.includes("test goal")); | ||
}); |
Oops, something went wrong.