Skip to content

Commit 76a89eb

Browse files
Update tests.js
button url property was in lower case
1 parent f52f55f commit 76a89eb

File tree

1 file changed

+39
-17
lines changed
  • exercises/03.3-component-properties

1 file changed

+39
-17
lines changed

exercises/03.3-component-properties/tests.js

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,63 @@ import renderer from "react-test-renderer";
66
jest.mock("react-dom", () => ({ render: jest.fn() }));
77

88
test("ReactDOM.render needs to be called once", () => {
9-
expect(ReactDOM.render.mock.calls.length).toBe(1);
9+
expect(ReactDOM.render.mock.calls.length).toBe(1);
1010
});
1111

1212
test("Component title is being passed properly", () => {
13-
const component = ReactDOM.render.mock.calls[0][0];
14-
expect(component.props.title).toBe("Bob Dylan");
13+
const component = ReactDOM.render.mock.calls[0][0];
14+
expect(component.props.title).toBe("Bob Dylan");
1515
});
1616

1717
test("Component imageUrl is being passed properly", () => {
18-
const component = ReactDOM.render.mock.calls[0][0];
19-
expect(component.props.imageUrl).toBe("https://ucarecdn.com/f8cf81eb-3bab-4bba-9431-668884eab174/-/resize/300x/");
18+
const component = ReactDOM.render.mock.calls[0][0];
19+
if (component.props.imageUrl != undefined) {
20+
expect(component.props.imageUrl).toBe("https://ucarecdn.com/f8cf81eb-3bab-4bba-9431-668884eab174/-/resize/300x/");
21+
22+
} else if (component.props.imageURL != undefined) {
23+
expect(component.props.imageURL).toBe("https://ucarecdn.com/f8cf81eb-3bab-4bba-9431-668884eab174/-/resize/300x/");
24+
25+
} else {
26+
throw Error('I was expecting the property imageURL')
27+
28+
29+
}
30+
2031
});
2132

2233
test("Component description is being passed properly", () => {
23-
const component = ReactDOM.render.mock.calls[0][0];
24-
expect(component.props.description).toBe(
25-
"Bob Dylan (born Robert Allen Zimmerman, May 24, 1941) is an American singer-songwriter."
26-
);
34+
const component = ReactDOM.render.mock.calls[0][0];
35+
expect(component.props.description).toBe(
36+
"Bob Dylan (born Robert Allen Zimmerman, May 24, 1941) is an American singer-songwriter."
37+
);
2738
});
2839

2940
test("Component buttonUrl is being passed properly", () => {
30-
const component = ReactDOM.render.mock.calls[0][0];
31-
expect(component.props.buttonUrl).toBe(
32-
"https://en.wikipedia.org/wiki/Bob_Dylan"
33-
);
41+
const component = ReactDOM.render.mock.calls[0][0];
42+
43+
if (component.props.buttonUrl != undefined) {
44+
expect(component.props.buttonUrl).toBe(
45+
"https://en.wikipedia.org/wiki/Bob_Dylan"
46+
);
47+
} else if (component.props.buttonURL != undefined) {
48+
expect(component.props.buttonURL).toBe(
49+
"https://en.wikipedia.org/wiki/Bob_Dylan"
50+
);
51+
} else {
52+
throw Error('I was expecting the property buttonURL')
53+
54+
55+
}
3456
});
3557

3658
test("Component buttonLabel is being passed properly", () => {
37-
const component = ReactDOM.render.mock.calls[0][0];
38-
expect(component.props.buttonLabel).toBe("Go to wikipedia");
59+
const component = ReactDOM.render.mock.calls[0][0];
60+
expect(component.props.buttonLabel).toBe("Go to wikipedia");
3961
});
4062

4163
test("The component should return the exact HTML", () => {
42-
const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
43-
expect(tree).toMatchInlineSnapshot(`
64+
const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
65+
expect(tree).toMatchInlineSnapshot(`
4466
<div
4567
className="card m-5"
4668
>

0 commit comments

Comments
 (0)