@gisce/react-ooui 1.1.28 → 1.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -16,4 +16,15 @@ describe("A IconMapper instance", () => {
16
16
  const icon = iconMapper("gtk-find-and-replace");
17
17
  expect(icon).toBe(findAndReplaceIcon);
18
18
  })
19
+ test("should return gtk-go", () => {
20
+ const findAndReplaceIcon = Icons.FileSearchOutlined;
21
+ const icon = iconMapper("gtk-find-and-replace");
22
+ expect(icon).toBe(findAndReplaceIcon);
23
+ })
24
+ describe("If key doesn't exist in iconMapper", () => {
25
+ test("should return undefined", () => {
26
+ const icon = iconMapper("gtk-foo-bar");
27
+ expect(icon).toBe(undefined);
28
+ })
29
+ })
19
30
  });
@@ -103,8 +103,7 @@ const iconMapping: { [key: string]: string } = {
103
103
  export default (key: string) => {
104
104
  if (key.indexOf("gtk-") !== -1) {
105
105
  const rootIcon = key.replace("gtk-", "").replace(/\-/g, "_");
106
- const newKey = `STOCK_${rootIcon.toUpperCase()}`;
107
- return getIconForKey(iconMapping[newKey]);
106
+ key = `STOCK_${rootIcon.toUpperCase()}`;
108
107
  }
109
108
 
110
109
  if (iconMapping.hasOwnProperty(key)) {
@@ -114,7 +113,7 @@ export default (key: string) => {
114
113
  return getIconForKey(key);
115
114
  };
116
115
 
117
- function toCamelCase(key: string) : string {
116
+ function toCamelCase(key: string): string {
118
117
  return `${key
119
118
  .split("-")
120
119
  .map((word) =>
@@ -126,7 +125,8 @@ function toCamelCase(key: string) : string {
126
125
  .join("")}`;
127
126
  }
128
127
 
129
- function getIconForKey(IconCamelCase: string) {
128
+ function getIconForKey(key: string) {
129
+ let IconCamelCase = key.charAt(0).toUpperCase() + key.slice(1); // Capitalize first letter
130
130
  if (IconCamelCase.indexOf("-") !== -1) {
131
131
  IconCamelCase = toCamelCase(IconCamelCase);
132
132
  }