Commit 3656c560 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

chore(deps): update various cozy libs: cozy-bar, cozy-client, cozy-harvest, cozy-scripts, cozy-ui

parent 066ebb9c
......@@ -12,7 +12,8 @@ import { profileData } from '../../../tests/__mocks__/profile.mock'
import configureStore from 'redux-mock-store'
import { Button } from '@material-ui/core'
import ActionBegin from './ActionBegin'
import { act } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import { ecogesturesData } from '../../../tests/__mocks__/ecogesturesData.mock'
jest.mock('cozy-ui/transpiled/react/I18n', () => {
return {
......@@ -34,6 +35,14 @@ jest.mock('services/action.service', () => {
}
})
})
const mockImportIconbyId = jest.fn()
jest.mock('utils/utils', () => {
return {
importIconbyId: jest.fn(() => {
return mockImportIconbyId
}),
}
})
const mockStore = configureStore([])
describe('ActionBegin component', () => {
......@@ -45,6 +54,8 @@ describe('ActionBegin component', () => {
profile: profileData,
},
})
mockImportIconbyId.mockReturnValue('')
const wrapper = mount(
<Provider store={store}>
<ActionBegin
......@@ -66,6 +77,7 @@ describe('ActionBegin component', () => {
AllEcogestureData[5],
AllEcogestureData[2],
])
mockImportIconbyId.mockReturnValue('')
const store = mockStore({
ecolyo: {
challenge: userChallengeData[1],
......@@ -76,6 +88,7 @@ describe('ActionBegin component', () => {
const wrapper = mount(
<Provider store={store}>
<ActionBegin
action={ecogesturesData[1]}
setShowList={jest.fn()}
userChallenge={userChallengeData[1]}
/>
......@@ -85,7 +98,7 @@ describe('ActionBegin component', () => {
await new Promise(resolve => setTimeout(resolve))
wrapper.update()
})
expect(wrapper.find('.action-title').text()).toBe('Bonhomme de neige')
expect(wrapper.find('.action-title').text()).toBe('Coup de vent')
})
it('should render chosen action ', async () => {
const store = mockStore({
......@@ -95,6 +108,8 @@ describe('ActionBegin component', () => {
profile: profileData,
},
})
mockImportIconbyId.mockReturnValue('')
const wrapper = mount(
<Provider store={store}>
<ActionBegin
......@@ -118,6 +133,8 @@ describe('ActionBegin component', () => {
profile: profileData,
},
})
mockImportIconbyId.mockReturnValue('')
const wrapper = mount(
<Provider store={store}>
<ActionBegin
......@@ -146,6 +163,8 @@ describe('ActionBegin component', () => {
profile: profileData,
},
})
mockImportIconbyId.mockReturnValue('')
const wrapper = mount(
<Provider store={store}>
<ActionBegin
......
......@@ -67,11 +67,17 @@ const ActionBegin: React.FC<ActionBeginProps> = ({
}, [client, isProfileTypeCompleted, fluidTypes, action, currentAction])
useEffect(() => {
if (currentAction) {
importIconbyId(currentAction.id, 'ecogesture').then(icon => {
icon ? setActionIcon(icon) : setActionIcon(defaultIcon)
})
async function handleEcogestureIcon() {
if (currentAction) {
const icon = await importIconbyId(currentAction.id, 'ecogesture')
if (icon) {
setActionIcon(icon)
} else {
setActionIcon(defaultIcon)
}
}
}
handleEcogestureIcon()
}, [currentAction])
return (
......
......@@ -21,6 +21,14 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => {
}),
}
})
const mockImportIconbyId = jest.fn()
jest.mock('utils/utils', () => {
return {
importIconbyId: jest.fn(() => {
return mockImportIconbyId
}),
}
})
describe('ActionCard component', () => {
it('should be rendered correctly', () => {
const store = mockStore({
......
......@@ -53,9 +53,15 @@ const ActionCard: React.FC<ActionCardProps> = ({
])
useEffect(() => {
importIconbyId(action.id, 'ecogesture').then(icon => {
icon ? setActionIcon(icon) : setActionIcon(defaultIcon)
})
async function handleEcogestureIcon() {
const icon = await importIconbyId(action.id, 'ecogesture')
if (icon) {
setActionIcon(icon)
} else {
setActionIcon(defaultIcon)
}
}
handleEcogestureIcon()
}, [action])
return (
......
......@@ -9,7 +9,7 @@ import ActionDone from './ActionDone'
import { Button } from '@material-ui/core'
import * as reactRedux from 'react-redux'
import * as challengeActions from 'store/challenge/challenge.actions'
import { act } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import UsageEventService from 'services/usageEvent.service'
const mockStore = configureStore([])
......
......@@ -10,7 +10,7 @@ import configureStore from 'redux-mock-store'
import { Button } from '@material-ui/core'
import * as reactRedux from 'react-redux'
import * as challengeActions from 'store/challenge/challenge.actions'
import { act } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import UsageEventService from 'services/usageEvent.service'
jest.mock('cozy-ui/transpiled/react/I18n', () => {
......
......@@ -11,6 +11,8 @@ import ActionOnGoing from './ActionOnGoing'
import { UserActionState } from 'enum/userAction.enum'
import { DateTime } from 'luxon'
import EcogestureModal from 'components/Ecogesture/EcogestureModal'
import { UserAction } from 'models'
import { act } from 'react-dom/test-utils'
jest.mock('cozy-ui/transpiled/react/I18n', () => {
return {
......@@ -21,11 +23,19 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => {
}),
}
})
const mockImportIconbyId = jest.fn()
jest.mock('utils/utils', () => {
return {
importIconbyId: jest.fn(() => {
return mockImportIconbyId
}),
}
})
const mockStore = configureStore([])
describe('ActionOnGoing component', () => {
const userAction = {
ecogesture: defaultEcogestureData[1],
const userAction: UserAction = {
ecogesture: null,
startDate: DateTime.local().setZone('utc', {
keepLocalTime: true,
}),
......@@ -45,9 +55,15 @@ describe('ActionOnGoing component', () => {
<ActionOnGoing userAction={userAction} />
</Provider>
)
expect(wrapper).toMatchSnapshot()
})
it('should click on button onpen ecogesture Modal', async () => {
it('should click on button open ecogesture Modal', async () => {
const userAction1: UserAction = {
ecogesture: defaultEcogestureData[1],
startDate: null,
state: UserActionState.ONGOING,
}
const store = mockStore({
ecolyo: {
challenge: userChallengeData[1],
......@@ -57,9 +73,13 @@ describe('ActionOnGoing component', () => {
})
const wrapper = mount(
<Provider store={store}>
<ActionOnGoing userAction={userAction} />
<ActionOnGoing userAction={userAction1} />
</Provider>
)
await act(async () => {
await new Promise(resolve => setTimeout(resolve))
wrapper.update()
})
wrapper
.find(Button)
.first()
......
......@@ -5,7 +5,7 @@ import { Provider } from 'react-redux'
import configureStore from 'redux-mock-store'
import { profileData } from '../../../tests/__mocks__/profile.mock'
import AnalysisConsumption from 'components/Analysis/AnalysisConsumption'
import { act } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import Button from '@material-ui/core/Button'
import StyledCard from 'components/CommonKit/Card/StyledCard'
import { globalStateData } from '../../../tests/__mocks__/globalStateData.mock'
......
......@@ -12,6 +12,18 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => {
}),
}
})
const mockImportIconbyId = jest.fn()
const mockFormatNumberValues = jest.fn()
jest.mock('utils/utils', () => {
return {
importIconbyId: jest.fn(() => {
return mockImportIconbyId
}),
formatNumberValues: jest.fn(() => {
return mockFormatNumberValues
}),
}
})
describe('ChallengeCardDone component', () => {
it('should be rendered correctly', () => {
......
......@@ -74,12 +74,21 @@ const ChallengeCardDone: React.FC<ChallengeCardDoneProps> = ({
}
useEffect(() => {
importIconbyId(userChallenge.id + '-1', 'duelResult').then(icon => {
icon ? setWinIcon(icon) : setWinIcon(defaultIcon)
})
importIconbyId(userChallenge.id + '-0', 'duelResult').then(icon => {
icon ? setLossIcon(icon) : setLossIcon(defaultIcon)
})
async function handleEcogestureIcon() {
const icon = await importIconbyId(userChallenge.id + '-1', 'duelResult')
if (icon) {
setWinIcon(icon)
} else {
setWinIcon(defaultIcon)
}
const icon2 = await importIconbyId(userChallenge.id + '-0', 'duelResult')
if (icon2) {
setLossIcon(icon2)
} else {
setLossIcon(defaultIcon)
}
}
handleEcogestureIcon()
}, [userChallenge])
return (
......
......@@ -26,6 +26,14 @@ jest.mock('services/challenge.service', () => {
}
})
})
const mockImportIconbyId = jest.fn()
jest.mock('utils/utils', () => {
return {
importIconbyId: jest.fn(() => {
return mockImportIconbyId
}),
}
})
const mockStore = configureStore([])
......
......@@ -55,13 +55,24 @@ const ChallengeCardUnlocked: React.FC<ChallengeCardUnlockedProps> = ({
} else {
return toggleNoFluidModal()
}
}, [client, dispatch, userChallenge, fluidTypes, toggleNoFluidModal])
}, [
fluidTypes.length,
statusRequirementOk,
client,
userChallenge,
dispatch,
toggleNoFluidModal,
])
useEffect(() => {
async function handleEcogestureIcon() {
const icon = await importIconbyId(userChallenge.id, 'challenge')
if (icon) {
setChallengeIcon(icon)
}
}
if (userChallenge) {
importIconbyId(userChallenge.id, 'challenge').then(icon => {
icon && setChallengeIcon(icon)
})
handleEcogestureIcon()
}
}, [userChallenge])
......
......@@ -44,7 +44,9 @@ exports[`ChallengeCardDone component should be rendered correctly 1`] = `
<span
className="text-18-bold"
>
challenge.card_done.saving 0,00€
challenge.card_done.saving function () {
return fn.apply(this, arguments);
}€
</span>
<br />
challenge.card_done.final_defi
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ChallengeNoFluidModal component should be rendered correctly opened 1`] = `
<ForwardRef(WithStyles)
<WithStyles(ForwardRef(Dialog))
aria-labelledby="accessibility-title"
classes={
Object {
......@@ -32,7 +32,7 @@ exports[`ChallengeNoFluidModal component should be rendered correctly opened 1`]
>
challenge_no_fluid_modal.content
</div>
<ForwardRef(WithStyles)
<WithStyles(ForwardRef(Button))
aria-label="challenge_no_fluid_modal.accessibility.button_validate"
classes={
Object {
......@@ -43,7 +43,7 @@ exports[`ChallengeNoFluidModal component should be rendered correctly opened 1`]
onClick={[MockFunction]}
>
challenge_no_fluid_modal.button_validate
</ForwardRef(WithStyles)>
</WithStyles(ForwardRef(Button))>
</div>
</ForwardRef(WithStyles)>
</WithStyles(ForwardRef(Dialog))>
`;
......@@ -2,22 +2,22 @@
exports[`StyledIconBorderedButton component test should render correctly SelectedIconButtonBase 1`] = `
<React.Fragment>
<ForwardRef(WithStyles)>
<WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))>
<StyledIcon
icon="icon"
size={20}
/>
</ForwardRef(WithStyles)>
</WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))>
</React.Fragment>
`;
exports[`StyledIconBorderedButton component test should render correctly UnselectedIconButtonBase 1`] = `
<React.Fragment>
<ForwardRef(WithStyles)>
<WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))>
<StyledIcon
icon="icon"
size={20}
/>
</ForwardRef(WithStyles)>
</WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))>
</React.Fragment>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`StyledIconButton component test should render correctly StyledIconButton 1`] = `
<ForwardRef(WithStyles)>
<WithStyles(WithStyles(ForwardRef(IconButton)))>
<StyledIcon
icon="icon"
size={15}
/>
</ForwardRef(WithStyles)>
</WithStyles(WithStyles(ForwardRef(IconButton)))>
`;
......@@ -13,7 +13,7 @@ exports[`ConnectionNotFound component test should correctly render connection no
<div
className="knotfound-button"
>
<ForwardRef(WithStyles)
<WithStyles(ForwardRef(Button))
aria-label="konnector_form.accessibility.button_install"
classes={
Object {
......@@ -24,7 +24,7 @@ exports[`ConnectionNotFound component test should correctly render connection no
onClick={[Function]}
>
konnector_form.button_install
</ForwardRef(WithStyles)>
</WithStyles(ForwardRef(Button))>
</div>
</div>
`;
import React from 'react'
import { mount } from 'enzyme'
import { DateTime } from 'luxon'
import * as reactRedux from 'react-redux'
import { act } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import { globalStateData } from '../../../tests/__mocks__/globalStateData.mock'
import { Provider } from 'react-redux'
import configureStore from 'redux-mock-store'
......
......@@ -21,9 +21,16 @@ const DuelEmptyValueModal: React.FC<DuelEmptyValueModalProps> = ({
const { t } = useI18n()
const [emptyIcon, setEmptyIcon] = useState<string>(defaultIcon)
useEffect(() => {
importIconbyId('emptyValue', 'duel').then(icon => {
icon ? setEmptyIcon(icon) : setEmptyIcon(defaultIcon)
})
async function handleEcogestureIcon() {
const icon = await importIconbyId('emptyValue', 'duel')
if (icon) {
setEmptyIcon(icon)
} else {
setEmptyIcon(defaultIcon)
}
}
handleEcogestureIcon()
}, [])
return (
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment