-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHero.spec.tsx
43 lines (33 loc) · 1.28 KB
/
Hero.spec.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
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import Hero from './Hero';
// Configure enzyme for react 17
Enzyme.configure({ adapter: new Adapter() });
// common vars
let wrapper: ReactWrapper<typeof Hero>;
describe('Hero component', () => {
beforeAll(() => {
wrapper = mount(<Hero />);
});
afterAll(() => {
wrapper.unmount();
});
it('should load correctly', () => {
expect(wrapper.find('.hero').exists()).toBeTruthy();
});
it('should have correct heading tagline', () => {
const heroTitle = wrapper.find('.hero__title');
expect(heroTitle.exists()).toBeTruthy();
expect(heroTitle.at(0).text()).not.toBe('');
expect(heroTitle.at(0).text()).toBe('Welcome to ItemManager');
});
it('should have correct subheading tagline', () => {
const heroSubtitle = wrapper.find('.hero__subtitle');
expect(heroSubtitle.exists()).toBeTruthy();
expect(heroSubtitle.at(0).text()).not.toBe('');
expect(heroSubtitle.at(0).text()).toBe('Find anything you want, sell what you don’t need.');
});
it('should have svg background animated icon', () => {
expect(wrapper.find('.hero__icon').exists()).toBeTruthy();
});
});