fleet/frontend/utilities/strings/stringUtils.tests.ts
Jacob Shandling 204aa49ab9
UI: Title Case bug (#11786)
## Addresses #11737

- Write function to enforce Fleet sentence-casing standards
- Apply it to this bug

<img width="642" alt="Screenshot 2023-05-18 at 12 43 20 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/670f4f8d-1c23-4609-bb23-c38038e9bbd8">

*NOTE - this (the host details) endpoint currently returns label names
in Sentence Case – this solution deals with only the UI presentation,
but it might be worth changing the API response in the future:
<img width="369" alt="Screenshot 2023-05-18 at 12 48 58 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/27236524-9c0a-4818-8a74-f445b5765d94">

## Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` 
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-05-18 13:40:04 -07:00

23 lines
973 B
TypeScript

import { enforceFleetSentenceCasing } from "./stringUtils";
describe("enforceFleetSentenceCasing utility", () => {
it("fixes a Title Cased String with no ignore words", () => {
expect(enforceFleetSentenceCasing("All Hosts")).toEqual("All hosts");
expect(enforceFleetSentenceCasing("all Hosts")).toEqual("All hosts");
expect(enforceFleetSentenceCasing("all hosts")).toEqual("All hosts");
expect(enforceFleetSentenceCasing("All HosTs ")).toEqual("All hosts");
});
it("fixes a title cased string while ignoring special words in various places ", () => {
expect(enforceFleetSentenceCasing("macOS")).toEqual("macOS");
expect(enforceFleetSentenceCasing("macOS Settings")).toEqual(
"macOS settings"
);
expect(
enforceFleetSentenceCasing("osquery shouldn't be Capitalized")
).toEqual("osquery shouldn't be capitalized");
});
expect(enforceFleetSentenceCasing("fleet uses MySQL")).toEqual(
"Fleet uses MySQL"
);
});