1 | import React from 'react';
|
2 | import { shallow, mount } from 'enzyme';
|
3 | import { Counter } from './state.js';
|
4 |
|
5 | import App from './App';
|
6 |
|
7 | describe('App', () => {
|
8 | const counter = new Counter();
|
9 | let component;
|
10 |
|
11 | it('renders correctly', () => {
|
12 | component = mount(<App counter={counter} />);
|
13 | });
|
14 | it('should contain one "H2" element', () => {
|
15 | expect(component.find('h2').length).toBe(1);
|
16 | });
|
17 | it('should contain three "button" elements', () => {
|
18 | expect(component.find('button').length).toBe(3);
|
19 | });
|
20 | it('should increase counter', () => {
|
21 | counter.increase();
|
22 | counter.increase();
|
23 | expect(counter.value).toEqual(2);
|
24 | });
|
25 | it('should double counter', () => {
|
26 | counter.double();
|
27 | expect(counter.value).toEqual(4);
|
28 | });
|
29 | it('should decrease counter', () => {
|
30 | counter.decrease();
|
31 | expect(counter.value).toEqual(3);
|
32 | });
|
33 | });
|
34 |
|
\ | No newline at end of file |