-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce sentence casing when writing IMDI
- Loading branch information
Showing
12 changed files
with
87 additions
and
39 deletions.
There are no files selected for viewing
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,5 @@ | ||
Use vitest, not jest. | ||
Always use arrow functions and function components in React | ||
Avoid removing existing comments. | ||
Avoid adding a comment like "// add this line". | ||
If you think you might need access to another file, stop and ask me for it. |
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,35 @@ | ||
import ImdiGenerator, { IMDIMode } from "./ImdiGenerator"; | ||
import { Project } from "../model/Project/Project"; | ||
import temp from "temp"; | ||
import { setResultXml, value } from "../other/xmlUnitTestUtils"; | ||
|
||
let project: Project; | ||
const projectDir = temp.mkdirSync("lameta imdi generator vocab test"); | ||
describe("ImdiGenerator genre handling", () => { | ||
beforeAll(async () => { | ||
temp.track(); | ||
project = Project.fromDirectory(projectDir); | ||
await project.descriptionFolder.addFileForTestAsync(randomFileName()); | ||
await project.otherDocsFolder.addFileForTestAsync(randomFileName()); | ||
}); | ||
it("should convert genre to sentence case", () => { | ||
const session = project.addSession(); | ||
session.properties.setText("genre", "procedural_discourse"); | ||
const imdi = ImdiGenerator.generateSession( | ||
IMDIMode.RAW_IMDI, | ||
session, | ||
project, | ||
true | ||
); | ||
setResultXml(imdi); | ||
|
||
// Check for correct genre case in the output | ||
expect(value("//Session/MDGroup/Content/Genre")).toBe( | ||
"Procedural discourse" | ||
); | ||
}); | ||
}); | ||
|
||
function randomFileName() { | ||
return Math.random().toString(36).substring(7) + ".test.txt"; | ||
} |
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
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
import { vi, describe, it, beforeAll, beforeEach, expect } from "vitest"; | ||
import { CapitalCase, safeSentenceCase } from "./case"; | ||
import { capitalCase, sentenceCaseUnlessAcronym } from "./case"; | ||
|
||
describe("CapitalCase tests", () => { | ||
describe("capitalCase tests", () => { | ||
it("capitalizes", () => { | ||
expect(CapitalCase("hello")).toBe("Hello"); | ||
expect(CapitalCase("hello world")).toBe("Hello World"); | ||
expect(CapitalCase("HELlo WoRld")).toBe("Hello World"); | ||
expect(capitalCase("hello")).toBe("Hello"); | ||
expect(capitalCase("hello world")).toBe("Hello World"); | ||
expect(capitalCase("HELlo WoRld")).toBe("Hello World"); | ||
// Not totally clear what the right answer would be here: | ||
expect(CapitalCase(" hello world")).toBe(" Hello World"); | ||
expect(CapitalCase("explicación")).toBe("Explicación"); | ||
expect(CapitalCase("")).toBe(""); | ||
expect(capitalCase(" hello world")).toBe(" Hello World"); | ||
expect(capitalCase("explicación")).toBe("Explicación"); | ||
expect(capitalCase("")).toBe(""); | ||
}); | ||
}); | ||
|
||
describe("safeSentenceCase tests", () => { | ||
it("capitalizes", () => { | ||
expect(safeSentenceCase("hello")).toBe("Hello"); | ||
expect(safeSentenceCase("hello world")).toBe("Hello world"); | ||
expect(safeSentenceCase("HELlo WoRld")).toBe("Hello world"); | ||
expect(sentenceCaseUnlessAcronym("hello")).toBe("Hello"); | ||
expect(sentenceCaseUnlessAcronym("hello world")).toBe("Hello world"); | ||
expect(sentenceCaseUnlessAcronym("HELlo WoRld")).toBe("Hello world"); | ||
// Not totally clear what the right answer would be here: | ||
expect(safeSentenceCase("")).toBe(""); | ||
expect(sentenceCaseUnlessAcronym("")).toBe(""); | ||
}); | ||
it("does not capitalize some known mixed-case things", () => { | ||
expect(safeSentenceCase("FLEx")).toBe("FLEx"); | ||
expect(safeSentenceCase("FLEx project")).toBe("FLEx project"); | ||
expect(safeSentenceCase("the FLEx Project")).toBe("The FLEx project"); | ||
expect(sentenceCaseUnlessAcronym("FLEx")).toBe("FLEx"); | ||
expect(sentenceCaseUnlessAcronym("FLEx project")).toBe("FLEx project"); | ||
expect(sentenceCaseUnlessAcronym("the FLEx Project")).toBe( | ||
"The FLEx project" | ||
); | ||
}); | ||
|
||
it("does not capitalize acronyms", () => { | ||
expect(safeSentenceCase("on AWS")).toBe("On AWS"); | ||
expect(sentenceCaseUnlessAcronym("on AWS")).toBe("On AWS"); | ||
}); | ||
}); |
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