-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebd50b4
commit 26cf6f7
Showing
157 changed files
with
5,862 additions
and
5,046 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,57 @@ | ||
import { describe, test, expect } from "vitest"; | ||
import { removeEmptyKeys } from "./ologApi"; | ||
|
||
describe("removeEmtpyKeys util", () => { | ||
test("Empty lists are removed", () => { | ||
const result = removeEmptyKeys({ | ||
foo: ["bar"], | ||
baz: [] | ||
}); | ||
|
||
test("Empty lists are removed", () => { | ||
|
||
const result = removeEmptyKeys({ | ||
foo: ["bar"], | ||
baz: [] | ||
}) | ||
|
||
expect(result).toEqual({ | ||
foo: ["bar"] | ||
}) | ||
|
||
expect(result).toEqual({ | ||
foo: ["bar"] | ||
}); | ||
|
||
test("empty strings are removed", () => { | ||
|
||
const result = removeEmptyKeys({ | ||
foo: "bar", | ||
baz: "" | ||
}) | ||
|
||
expect(result).toEqual({ | ||
foo: "bar" | ||
}) | ||
|
||
}); | ||
|
||
test("empty strings are removed", () => { | ||
const result = removeEmptyKeys({ | ||
foo: "bar", | ||
baz: "" | ||
}); | ||
|
||
test("null and undefined values are removed", () => { | ||
|
||
const result = removeEmptyKeys({ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined | ||
}) | ||
|
||
expect(result).toEqual({ | ||
foo: "bar" | ||
}) | ||
|
||
|
||
expect(result).toEqual({ | ||
foo: "bar" | ||
}); | ||
}); | ||
|
||
test("null and undefined values are removed", () => { | ||
const result = removeEmptyKeys({ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined | ||
}); | ||
|
||
test("exceptions are excluded", () => { | ||
|
||
const result = removeEmptyKeys({ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined, | ||
whamo: [] | ||
}, ["baz", "phooey", "whamo"]); | ||
|
||
expect(result).toEqual({ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined, | ||
whamo: [] | ||
}) | ||
|
||
|
||
expect(result).toEqual({ | ||
foo: "bar" | ||
}); | ||
}); | ||
|
||
test("exceptions are excluded", () => { | ||
const result = removeEmptyKeys( | ||
{ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined, | ||
whamo: [] | ||
}, | ||
["baz", "phooey", "whamo"] | ||
); | ||
|
||
expect(result).toEqual({ | ||
foo: "bar", | ||
baz: null, | ||
phooey: undefined, | ||
whamo: [] | ||
}); | ||
}); | ||
}); | ||
}); |
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,40 +1,37 @@ | ||
import { Avatar } from "@mui/material"; | ||
import React from "react"; | ||
|
||
/* | ||
* Demonstration by MUI of transforming string into a unique hex value | ||
*/ | ||
const stringToColor = (string) => { | ||
let hash = 0; | ||
let i; | ||
|
||
/* eslint-disable no-bitwise */ | ||
for (i = 0; i < string.length; i += 1) { | ||
hash = string.charCodeAt(i) + ((hash << 5) - hash); | ||
} | ||
|
||
let color = '#'; | ||
|
||
for (i = 0; i < 3; i += 1) { | ||
const value = (hash >> (i * 8)) & 0xff; | ||
color += `00${value.toString(16)}`.slice(-2); | ||
} | ||
/* eslint-enable no-bitwise */ | ||
|
||
return color; | ||
} | ||
let hash = 0; | ||
let i; | ||
|
||
/* eslint-disable no-bitwise */ | ||
for (i = 0; i < string.length; i += 1) { | ||
hash = string.charCodeAt(i) + ((hash << 5) - hash); | ||
} | ||
|
||
let color = "#"; | ||
|
||
for (i = 0; i < 3; i += 1) { | ||
const value = (hash >> (i * 8)) & 0xff; | ||
color += `00${value.toString(16)}`.slice(-2); | ||
} | ||
/* eslint-enable no-bitwise */ | ||
|
||
const UserAvatar = ({user, size=36, ...props}) => { | ||
return color; | ||
}; | ||
|
||
return ( | ||
<Avatar | ||
alt={user.userName} | ||
sx={{ width: size, height: size, bgcolor: stringToColor(user.userName) }} | ||
{...props} | ||
> | ||
{user.userName.slice(0,2)} | ||
</Avatar> | ||
) | ||
} | ||
const UserAvatar = ({ user, size = 36, ...props }) => { | ||
return ( | ||
<Avatar | ||
alt={user.userName} | ||
sx={{ width: size, height: size, bgcolor: stringToColor(user.userName) }} | ||
{...props} | ||
> | ||
{user.userName.slice(0, 2)} | ||
</Avatar> | ||
); | ||
}; | ||
|
||
export default UserAvatar; | ||
export default UserAvatar; |
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
Oops, something went wrong.