forked from negomi/react-burger-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubble.spec.js
More file actions
73 lines (61 loc) · 2.69 KB
/
bubble.spec.js
File metadata and controls
73 lines (61 loc) · 2.69 KB
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
'use strict';
import React from 'react';
import TestUtils from 'react-dom/test-utils';
import { expect } from 'chai';
import createShallowComponent from './utils/createShallowComponent';
import BurgerMenu from '../lib/BurgerMenu';
const Menu = BurgerMenu.bubble;
describe('bubble', () => {
let component, menuWrap, morphShape, svg, menu, closeButton, itemList, firstItem;
beforeEach(() => {
component = createShallowComponent(<Menu><div>An item</div></Menu>);
menuWrap = component.props.children[1];
morphShape = menuWrap.props.children[0];
svg = morphShape.props.children;
menu = menuWrap.props.children[1];
itemList = menu.props.children;
closeButton = menuWrap.props.children[2];
firstItem = menu.props.children.props.children[0];
});
it('has correct menuWrap styles', () => {
expect(menuWrap.props.style.position).to.equal('fixed');
expect(menuWrap.props.style.zIndex).to.equal(1100);
expect(menuWrap.props.style.width).to.equal('300px');
expect(menuWrap.props.style.height).to.equal('100%');
});
it('has correct menu styles', () => {
expect(menu.props.style.position).to.equal('fixed');
expect(menu.props.style.height).to.equal('100%');
expect(menu.props.style.opacity).to.equal(0);
expect(menu.props.style.boxSizing).to.equal('border-box');
});
it('has correct itemList styles', () => {
expect(itemList.props.style.height).to.equal('100%');
});
it('has correct item styles', () => {
expect(firstItem.props.style.display).to.equal('block');
expect(firstItem.props.style.outline).to.equal('none');
expect(firstItem.props.style.opacity).to.equal(0);
});
it('has correct morph shape styles', () => {
expect(morphShape.props.style.position).to.equal('absolute');
expect(morphShape.props.style.width).to.equal('100%');
expect(morphShape.props.style.height).to.equal('100%');
expect(morphShape.props.style.right).to.equal(0);
});
it('has correct initial SVG path', () => {
let path = svg.props.children;
expect(path.props.d).to.equal('M-7.312,0H0c0,0,0,113.839,0,400c0,264.506,0,400,0,400h-7.312V0z');
});
it('has correct close button styles', () => {
expect(closeButton.props.style.opacity).to.equal(0);
});
it('can be positioned on the right', () => {
component = TestUtils.renderIntoDocument(<Menu right><div>An item</div></Menu>);
menuWrap = TestUtils.findRenderedDOMComponentWithClass(component, 'bm-menu-wrap');
morphShape = TestUtils.findRenderedDOMComponentWithClass(component, 'bm-morph-shape');
expect(menuWrap.style.right).to.equal('0px');
expect(morphShape.style.transform).to.equal('rotateY(180deg)');
expect(morphShape.style.left).to.equal('0px');
});
});