|
|
@@ -1,19 +1,31 @@
|
|
|
import React from 'react';
|
|
|
import { shallow } from 'enzyme';
|
|
|
+import toJson from 'enzyme-to-json';
|
|
|
|
|
|
import BurgerMenu from '../components/BurgerMenu/BurgerMenu';
|
|
|
-import { HBar, NavWrapper } from '../components/BurgerMenu/style';
|
|
|
+import { HBar, HBar1, HBar3, NavWrapper } from '../components/BurgerMenu/style';
|
|
|
|
|
|
-it('should render three horizontal bars', () => {
|
|
|
- const MenuWindow = shallow(<BurgerMenu />);
|
|
|
- expect(MenuWindow.find(HBar).length).toBe(3);
|
|
|
+describe('should render three horizontal bars', () => {
|
|
|
+ it('contains HBar1, HBar, and HBar3', () => {
|
|
|
+ const MenuWindow = shallow(<BurgerMenu />);
|
|
|
+ expect(MenuWindow.contains(<HBar1 />)).toBeTrue;
|
|
|
+ expect(MenuWindow.contains(<HBar />)).toBeTrue;
|
|
|
+ expect(MenuWindow.contains(<HBar3 />)).toBeTrue;
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe('should correctly set styles of each bar', () => {
|
|
|
it('second bar disappears after clicking', () => {
|
|
|
const MenuWindow = shallow(<BurgerMenu />);
|
|
|
MenuWindow.find(NavWrapper).simulate('click');
|
|
|
- const Bar2 = MenuWindow.find(HBar).at(1);
|
|
|
- expect(Bar2.prop('style')).toEqual('opacity: 0;');
|
|
|
+ const Bar2 = MenuWindow.find(HBar);
|
|
|
+ expect(Bar2.prop('style').opacity).toBe(0);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('snapshot test', () => {
|
|
|
+ const MenuWindow = shallow(<BurgerMenu />);
|
|
|
+ expect(toJson(MenuWindow)).toMatchSnapshot();
|
|
|
+ MenuWindow.find(NavWrapper).simulate('click');
|
|
|
+ expect(toJson(MenuWindow)).toMatchSnapshot();
|
|
|
});
|
|
|
});
|