Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
f5c37598
Commit
f5c37598
authored
3 years ago
by
Guilhem CARRON
Browse files
Options
Downloads
Patches
Plain Diff
Add unsubsribe test
parent
713a873b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!367
Feat/us469 unsubscribe bilan
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Options/UnSubscribe.spec.tsx
+61
-0
61 additions, 0 deletions
src/components/Options/UnSubscribe.spec.tsx
src/components/Options/__snapshots__/UnSubscribe.spec.tsx.snap
+18
-0
18 additions, 0 deletions
...omponents/Options/__snapshots__/UnSubscribe.spec.tsx.snap
with
79 additions
and
0 deletions
src/components/Options/UnSubscribe.spec.tsx
0 → 100644
+
61
−
0
View file @
f5c37598
import
React
from
'
react
'
import
{
mount
}
from
'
enzyme
'
import
{
Provider
}
from
'
react-redux
'
import
{
createMockStore
,
mockInitialEcolyoState
,
}
from
'
../../../tests/__mocks__/store
'
import
*
as
profileActions
from
'
store/profile/profile.actions
'
import
UnSubscribe
from
'
./UnSubscribe
'
import
{
Button
}
from
'
@material-ui/core
'
jest
.
mock
(
'
cozy-ui/transpiled/react/I18n
'
,
()
=>
{
return
{
useI18n
:
jest
.
fn
(()
=>
{
return
{
t
:
(
str
:
string
)
=>
str
,
}
}),
}
})
const
mockUpdateProfile
=
jest
.
fn
()
jest
.
mock
(
'
services/profile.service
'
,
()
=>
{
return
jest
.
fn
(()
=>
{
return
{
updateProfile
:
mockUpdateProfile
,
}
})
})
// const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch')
const
updateProfileSpy
=
jest
.
spyOn
(
profileActions
,
'
updateProfile
'
)
describe
(
'
UnSubscribe component
'
,
()
=>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let
store
:
any
beforeEach
(()
=>
{
store
=
createMockStore
(
mockInitialEcolyoState
)
updateProfileSpy
.
mockClear
()
})
it
(
'
should be rendered correctly
'
,
()
=>
{
const
wrapper
=
mount
(
<
Provider
store
=
{
store
}
>
<
UnSubscribe
/>
</
Provider
>
).
getElement
()
expect
(
wrapper
).
toMatchSnapshot
()
})
it
(
'
should click on button and deactivate report
'
,
()
=>
{
const
wrapper
=
mount
(
<
Provider
store
=
{
store
}
>
<
UnSubscribe
/>
</
Provider
>
)
wrapper
.
find
(
Button
).
simulate
(
'
click
'
)
expect
(
updateProfileSpy
).
toHaveBeenCalledWith
({
sendAnalysisNotification
:
false
,
})
})
})
This diff is collapsed.
Click to expand it.
src/components/Options/__snapshots__/UnSubscribe.spec.tsx.snap
0 → 100644
+
18
−
0
View file @
f5c37598
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`UnSubscribe component should be rendered correctly 1`] = `
<Provider
store={
Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
}
}
>
<UnSubscribe />
</Provider>
`;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment