-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStarShipCard.test.tsx
113 lines (98 loc) · 2.6 KB
/
StarShipCard.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import '@testing-library/jest-dom';
import { describe, expect, test } from 'vitest';
import { render, screen } from '@testing-library/react';
import StarShipCard from '.';
const data = {
name: 'Solar Sailer',
model: 'Punworcca 116-class interstellar sloop',
manufacturer: 'Huppla Pasa Tisc Shipwrights Collective',
cost_in_credits: '35700',
length: '15.2',
max_atmosphering_speed: '1600',
crew: '3',
passengers: '11',
cargo_capacity: '240',
consumables: '7 days',
hyperdrive_rating: '1.5',
MGLT: 'unknown',
starship_class: 'yacht',
pilots: [],
films: ['https://swapi.dev/api/films/5/'],
created: '2014-12-20T18:37:56.969000Z',
edited: '2014-12-20T21:23:49.937000Z',
url: 'https://swapi.dev/api/starships/58/',
};
describe('Starship Card', () => {
test('should show starship card', () => {
render(
<StarShipCard data={data} isFavorite favoriteButtonOnClick={() => {}} />
);
expect(screen.getByTestId('starship-card')).toBeDefined();
});
test('should show notes text area', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-notes')).toBeDefined();
});
test('should show starship name', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-name')).toBeDefined();
});
test('should show starship manufacturer', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-manufacturer')).toBeDefined();
});
test('should show starship passengers', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-passengers')).toBeDefined();
});
test('should show starship favorite button', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-favorite')).toBeDefined();
});
test('should show starship image', () => {
render(
<StarShipCard
data={data}
isFavorite
favoriteButtonOnClick={() => {}}
isNotesBoxVisible
/>
);
expect(screen.getByTestId('starship-image')).toBeDefined();
});
});