Add user list component + snap to user functionality (#1749)

This commit is contained in:
Oliver Benns 2020-06-19 11:36:49 +01:00 committed by GitHub
parent 8f65e37dac
commit ca87ca6fe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 333 additions and 32 deletions

39
src/tests/clients.test.ts Normal file
View file

@ -0,0 +1,39 @@
import { getClientInitials } from "../clients";
describe("getClientInitials", () => {
it("returns substring if one name provided", () => {
const result = getClientInitials("Alan");
expect(result).toBe("AL");
});
it("returns initials", () => {
const result = getClientInitials("John Doe");
expect(result).toBe("JD");
});
it("returns correct initials if many names provided", () => {
const result = getClientInitials("John Alan Doe");
expect(result).toBe("JD");
});
it("returns single initial if 1 letter provided", () => {
const result = getClientInitials("z");
expect(result).toBe("Z");
});
it("trims trailing whitespace", () => {
const result = getClientInitials(" q ");
expect(result).toBe("Q");
});
it('returns "?" if falsey value provided', () => {
let result = getClientInitials("");
expect(result).toBe("?");
result = getClientInitials(undefined);
expect(result).toBe("?");
result = getClientInitials(null);
expect(result).toBe("?");
});
});