Skip to content

Commit 2114751

Browse files
committed
fix: tags
1 parent aaf77aa commit 2114751

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/Methods/Methods.test.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,14 @@ it("renders schema methods tags", () => {
150150
],
151151
},
152152
},
153-
tags: ["tag3", "tag4"],
153+
tags: [
154+
{
155+
name: "tag3",
156+
},
157+
{
158+
name: "tag4",
159+
}
160+
]
154161
},
155162
{
156163
result: {
@@ -172,7 +179,14 @@ it("renders schema methods tags", () => {
172179
],
173180
},
174181
},
175-
tags: ["salad", "mytag"],
182+
tags: [
183+
{
184+
name: "salad",
185+
},
186+
{
187+
name: "mytag",
188+
},
189+
],
176190
},
177191
],
178192
};

src/Tags/Tags.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ it("renders empty with empty tags", () => {
1111

1212
it("renders schema tags", () => {
1313
const div = document.createElement("div");
14-
const tags = ["salad", "mytag"];
14+
const tags = [
15+
{
16+
name: "salad",
17+
},
18+
{
19+
name: "mytag",
20+
}
21+
];
1522
ReactDOM.render(<Tags tags={tags} />, div);
1623
expect(div.innerHTML.includes("salad")).toBe(true);
1724
expect(div.innerHTML.includes("mytag")).toBe(true);

src/Tags/Tags.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { Chip } from "@material-ui/core";
44
const hashColor = require("hash-color-material");
55

66
interface IProps {
7-
tags?: string[];
7+
tags?: types.TagObject[];
88
}
99

1010
export default class Tags extends Component<IProps> {
1111
public render() {
12-
const { tags } = this.props;
12+
const { tags }: { tags?: any} = this.props;
1313
if (!tags || tags.length === 0) {
1414
return null;
1515
}
@@ -19,9 +19,10 @@ export default class Tags extends Component<IProps> {
1919
tags.map((tag: any, k: number) => {
2020
return (
2121
<Chip
22-
key={tag}
23-
label={tag}
24-
style={{ backgroundColor: hashColor.getColorFromString(tag, false) }} />
22+
key={tag.name}
23+
label={tag.name}
24+
style={{ backgroundColor: hashColor.getColorFromString(tag.name, false) }}
25+
/>
2526
);
2627
})
2728
}

0 commit comments

Comments
 (0)