Skip to content

Commit f01566d

Browse files
chernichenkoOleksandr Chernichenko
andauthored
V9.0.0 alpha.0 - Fixing tests (#210)
* fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests * fix tests Co-authored-by: Oleksandr Chernichenko <oleksandr.chernichenko@Oleksandr-Chernichenko.local>
1 parent 483d359 commit f01566d

30 files changed

+315
-27853
lines changed

package-lock.json

Lines changed: 65 additions & 27566 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"react": "^17.0.2",
5656
"react-dom": "^17.0.2",
5757
"react-image-magnify": "^2.7.4",
58-
"react-swipeable-views": "0.13.3",
58+
"react-swipeable-views": "^0.14.0",
5959
"react-swipeable-views-utils": "0.13.3",
6060
"react-visibility-sensor": "^5.1.1",
6161
"resize-observer-polyfill": "^1.5.1",

src/PWA.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const classes = {
1717

1818
const StyledPWAContextProvider = styled(PWAContext.Provider)(({ theme }) => ({
1919
[`& .${classes.body}`]: {
20-
'-webkit-tap-highlight-color': 'transparent',
20+
'WebkitTapHighlightColor?': 'transparent',
2121
},
2222

2323
[`& .${classes.a}`]: {

src/carousel/Carousel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const Carousel = React.forwardRef((props, ref) => {
9898
const classes = { ...defaultClasses, ...c }
9999

100100
const { selected, setSelected } = useSelected(props)
101-
const count = children && children.length
101+
const count = !!children ? children.length : 0
102102

103103
let Tag = infinite ? VirtualizeSwipeableViews : SwipeableViews
104104
Tag = autoplay ? AutoPlaySwipeableViews : Tag
@@ -140,6 +140,7 @@ const Carousel = React.forwardRef((props, ref) => {
140140
onMouseEnter={onMouseEnter}
141141
onMouseLeave={onMouseLeave}
142142
onClick={onClick}
143+
height={height}
143144
>
144145
{aboveAdornments}
145146
<Fill height={height}>
@@ -154,15 +155,15 @@ const Carousel = React.forwardRef((props, ref) => {
154155
interval={interval}
155156
containerStyle={{ alignItems: 'center' }}
156157
/>
157-
{arrows !== false && (
158+
{arrows !== false ? (
158159
<CarouselArrows
159160
className={arrows === 'desktop' ? classes.hideTouchArrows : null}
160161
selected={selected}
161162
setSelected={setSelected}
162163
count={count}
163164
infinite={infinite}
164165
/>
165-
)}
166+
) : <div />}
166167
{indicators && <CarouselDots count={count} selected={selected} />}
167168
</div>
168169
</Fill>

src/carousel/CarouselDots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ CarouselDots.propTypes = {
8181
/**
8282
* The total number of dots to show.
8383
*/
84-
count: PropTypes.number.isRequired,
84+
count: PropTypes.number,
8585

8686
/**
8787
* The index of the selected dot.

src/drawer/Drawer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default function Drawer({
9494
variant,
9595
showCloseButton,
9696
open,
97-
onClose,
97+
onClose = () => {},
9898
title,
9999
children,
100100
className,

src/nav/NavTab.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React, { useCallback } from 'react'
2-
import { styled } from '@mui/material/styles'
3-
import { Hidden, Fade, Tab, Paper } from '@mui/material'
2+
import { styled, useTheme } from '@mui/material/styles'
3+
import { Fade, Tab, Paper } from '@mui/material'
44
import PropTypes from 'prop-types'
55
import Link from '../link/Link'
6-
6+
import useMediaQuery from '@mui/material/useMediaQuery'
77
import { bindHover, bindPopover } from 'material-ui-popup-state'
88
import { usePopupState } from 'material-ui-popup-state/hooks'
9-
109
import HoverPopover from 'material-ui-popup-state/HoverPopover'
1110

1211
const PREFIX = 'RSFNavTab'
@@ -95,6 +94,8 @@ const Root = styled('div')(({ theme }) => ({
9594
*/
9695
const NavTab = function({ href, as, prefetch, children, classes: c = {}, ...props }) {
9796
const classes = { ...defaultClasses, ...c }
97+
const theme = useTheme()
98+
const isSmall = useMediaQuery(theme.breakpoints.down('sm'))
9899

99100
const popupState = usePopupState({
100101
variant: 'popover',
@@ -136,9 +137,8 @@ const NavTab = function({ href, as, prefetch, children, classes: c = {}, ...prop
136137
}}
137138
/>
138139
</Link>
139-
{!children ? null : (
140-
<Hidden smDown>
141-
<HoverPopover
140+
{(children && !isSmall) ? (
141+
<HoverPopover
142142
{...bindPopover(popupState)}
143143
className={classes.popover}
144144
anchorOrigin={{
@@ -163,8 +163,7 @@ const NavTab = function({ href, as, prefetch, children, classes: c = {}, ...prop
163163
{children}
164164
</Paper>
165165
</HoverPopover>
166-
</Hidden>
167-
)}
166+
) : null}
168167
</Root>
169168
)
170169
}

src/theme/createTheme.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { createTheme as createMuiTheme, adaptV4Theme } from '@mui/material/styles'
1+
import { createTheme, adaptV4Theme } from '@mui/material/styles'
2+
// import { createTheme } from '@mui/material/styles';
23
import merge from 'lodash/merge'
34

45
/**
@@ -8,11 +9,11 @@ import merge from 'lodash/merge'
89
* @return {Object} A material UI theme
910
*/
1011

11-
export default function createTheme(values = {}) {
12-
const theme = createMuiTheme(
12+
export default function createThemeFunc(values = {}) {
13+
const theme = createTheme(
1314
merge(
1415
{},
15-
adaptV4Theme({
16+
{
1617
zIndex: {
1718
modal: 999,
1819
amp: {
@@ -23,7 +24,7 @@ export default function createTheme(values = {}) {
2324
loadMaskOffsetTop: 64 + 56 + 4,
2425
drawerWidth: 330,
2526
components: {},
26-
}),
27+
},
2728
values,
2829
),
2930
)

test/Accordion.test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
AccordionSummary as ExpansionPanelSummary,
77
Accordion as ExpansionPanel,
88
} from '@mui/material'
9+
import { getFiberIndex } from './methods'
910

1011
describe('Accordion', () => {
1112
it('should be empty render without children', () => {
@@ -45,9 +46,9 @@ describe('Accordion', () => {
4546
).toBe(0)
4647
})
4748

48-
it.skip('should expand section on section click ', () => {
49+
it('should expand section on section click ', () => {
4950
wrapper
50-
.find(ExpansionPanelSummary)
51+
.find('.MuiButtonBase-root')
5152
.last()
5253
.simulate('click')
5354

@@ -59,10 +60,10 @@ describe('Accordion', () => {
5960
).toBe(true)
6061
})
6162

62-
it.skip('should verify that previous opened section is closed on new section click', () => {
63+
it('should verify that previous opened section is closed on new section click', () => {
6364
wrapper
64-
.find(ExpansionPanelSummary)
65-
.first()
65+
.find('.MuiButtonBase-root')
66+
.at(getFiberIndex(0))
6667
.simulate('click')
6768

6869
expect(
@@ -73,7 +74,7 @@ describe('Accordion', () => {
7374
).toBe(true)
7475

7576
wrapper
76-
.find(ExpansionPanelSummary)
77+
.find('.MuiButtonBase-root')
7778
.last()
7879
.simulate('click')
7980

@@ -96,10 +97,10 @@ describe('Accordion', () => {
9697
).toBe(1)
9798
})
9899

99-
it.skip('should close the section if clicked again on the same section', () => {
100+
it('should close the section if clicked again on the same section', () => {
100101
wrapper
101-
.find(ExpansionPanelSummary)
102-
.first()
102+
.find('.MuiButtonBase-root')
103+
.at(getFiberIndex(0))
103104
.simulate('click')
104105
expect(
105106
wrapper
@@ -109,8 +110,8 @@ describe('Accordion', () => {
109110
).toBe(true)
110111

111112
wrapper
112-
.find(ExpansionPanelSummary)
113-
.first()
113+
.find('.MuiButtonBase-root')
114+
.at(getFiberIndex(0))
114115
.simulate('click')
115116
expect(
116117
wrapper

test/BackToTop.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('BackToTop', () => {
3434
expect(wrapper.find(CustomIcon).exists()).toBe(true)
3535
})
3636

37-
it.skip('should show back to top button when scrolled more than showUnderY prop value', () => {
37+
it('should show back to top button when scrolled more than showUnderY prop value', () => {
3838
window.pageYOffset = 201
3939
wrapper = mount(<BackToTop showUnderY={200} />)
4040

@@ -44,32 +44,32 @@ describe('BackToTop', () => {
4444

4545
expect(wrapper.find(Fab).prop('style').visibility).toBe('hidden')
4646

47-
wrapper.find(Fab).simulate('click')
47+
wrapper.find('.MuiFab-root').last().simulate('click')
4848

4949
expect(wrapper.find(Fab).prop('style').visibility).toBe(undefined)
5050
})
5151

52-
it.skip('should scroll to top instantly if scroll position is more than instantBehaviorUnderY prop value', () => {
52+
it('should scroll to top instantly if scroll position is more than instantBehaviorUnderY prop value', () => {
5353
window.scrollY = 300
5454
wrapper = mount(<BackToTop instantBehaviorUnderY={250} />)
5555

5656
act(() => {
5757
map.scroll()
5858
})
5959

60-
wrapper.find(Fab).simulate('click')
60+
wrapper.find('.MuiFab-root').last().simulate('click')
6161
expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'auto', left: 0, top: 0 })
6262
})
6363

64-
it.skip('should scroll to top smoothly if scroll position is less than instantBehaviorUnderY prop value', () => {
64+
it('should scroll to top smoothly if scroll position is less than instantBehaviorUnderY prop value', () => {
6565
window.pageYOffset = 201
6666
wrapper = mount(<BackToTop instantBehaviorUnderY={250} />)
6767

6868
act(() => {
6969
map.scroll()
7070
})
7171

72-
wrapper.find(Fab).simulate('click')
72+
wrapper.find('.MuiFab-root').last().simulate('click')
7373
expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'smooth', left: 0, top: 0 })
7474
})
7575
})

0 commit comments

Comments
 (0)