Random case vaultId
This commit is contained in:
parent
a86a056888
commit
ff02fee6a5
5 changed files with 49 additions and 24 deletions
11
frontend/test-client/src/utils/random-casing.test.ts
Normal file
11
frontend/test-client/src/utils/random-casing.test.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { randomCasing } from "./random-casing";
|
||||
|
||||
describe("randomCasing", () => {
|
||||
it("simple test", () => {
|
||||
const input =
|
||||
"hello, this is a really long string with a lot of characters";
|
||||
const result = randomCasing(input);
|
||||
expect(result.toLowerCase()).toBe(input.toLowerCase());
|
||||
expect(result).not.toBe(input);
|
||||
});
|
||||
});
|
||||
10
frontend/test-client/src/utils/random-casing.ts
Normal file
10
frontend/test-client/src/utils/random-casing.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export function randomCasing(str: string): string {
|
||||
const chars = str.split("");
|
||||
const randomCasedChars = chars.map((char) => {
|
||||
if (Math.random() < 0.5) {
|
||||
return char.toUpperCase();
|
||||
}
|
||||
return char.toLowerCase();
|
||||
});
|
||||
return randomCasedChars.join("");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue