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
0374df5e
Commit
0374df5e
authored
1 year ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
test(rtl): welcome modal
parent
a14a1f7e
No related branches found
No related tags found
2 merge requests
!1062
2.7 Release
,
!1059
test(rtl): welcome modal
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/WelcomeModal/WelcomeModal.spec.tsx
+34
-38
34 additions, 38 deletions
src/components/WelcomeModal/WelcomeModal.spec.tsx
src/components/WelcomeModal/__snapshots__/WelcomeModal.spec.tsx.snap
+105
-1399
105 additions, 1399 deletions
...nts/WelcomeModal/__snapshots__/WelcomeModal.spec.tsx.snap
with
139 additions
and
1437 deletions
src/components/WelcomeModal/WelcomeModal.spec.tsx
+
34
−
38
View file @
0374df5e
import
{
Button
,
IconButton
}
from
'
@material-ui/core
'
import
{
render
,
screen
}
from
'
@testing-library/react
'
import
{
mount
}
from
'
enzyme
'
import
userEvent
from
'
@testing-library/user-event
'
import
toJson
from
'
enzyme-to-json
'
import
React
from
'
react
'
import
React
from
'
react
'
import
{
Provider
}
from
'
react-redux
'
import
{
Provider
}
from
'
react-redux
'
import
*
as
profileActions
from
'
store/profile/profile.slice
'
import
*
as
profileActions
from
'
store/profile/profile.slice
'
...
@@ -41,58 +40,55 @@ jest.mock('services/profile.service')
...
@@ -41,58 +40,55 @@ jest.mock('services/profile.service')
const
updateProfileSpy
=
jest
.
spyOn
(
profileActions
,
'
updateProfile
'
)
const
updateProfileSpy
=
jest
.
spyOn
(
profileActions
,
'
updateProfile
'
)
describe
(
'
WelcomeModal component
'
,
()
=>
{
describe
(
'
WelcomeModal component
'
,
()
=>
{
beforeEach
(()
=>
{
jest
.
clearAllMocks
()
})
const
store
=
createMockEcolyoStore
()
const
store
=
createMockEcolyoStore
()
it
(
'
should be rendered correctly
'
,
()
=>
{
it
(
'
should be rendered correctly
'
,
()
=>
{
const
compon
ent
=
mount
(
const
{
baseElem
ent
}
=
render
(
<
Provider
store
=
{
store
}
>
<
Provider
store
=
{
store
}
>
<
WelcomeModal
open
=
{
true
}
/>
<
WelcomeModal
open
=
{
true
}
/>
</
Provider
>
</
Provider
>
)
)
expect
(
toJson
(
component
)).
toMatchSnapshot
()
expect
(
baseElement
).
toMatchSnapshot
()
expect
(
screen
.
getByRole
(
'
dialog
'
)).
toBeInTheDocument
()
})
})
it
(
'
should not be rendered
'
,
()
=>
{
it
(
'
should not be rendered
'
,
()
=>
{
const
component
=
mount
(
const
{
container
}
=
render
(
<
Provider
store
=
{
store
}
>
<
Provider
store
=
{
store
}
>
<
WelcomeModal
open
=
{
false
}
/>
<
WelcomeModal
open
=
{
false
}
/>
</
Provider
>
</
Provider
>
)
)
expect
(
toJson
(
component
)).
toMatchSnapshot
()
expect
(
container
.
firstChild
).
toBeNull
()
expect
(
screen
.
queryByRole
(
'
dialog
'
)).
not
.
toBeInTheDocument
()
})
})
it
(
'
should send mail and update profile when user click on the ok button
'
,
async
()
=>
{
describe
(
'
should test modal interactivity
'
,
()
=>
{
const
component
=
mount
(
beforeEach
(()
=>
{
<
Provider
store
=
{
store
}
>
render
(
<
WelcomeModal
open
=
{
true
}
/>
<
Provider
store
=
{
store
}
>
</
Provider
>
<
WelcomeModal
open
=
{
true
}
/>
)
</
Provider
>
component
.
find
(
Button
).
first
().
simulate
(
'
click
'
)
)
expect
(
mockSendMail
).
toHaveBeenCalled
()
})
expect
(
updateProfileSpy
).
toHaveBeenCalledWith
({
it
(
'
should send mail and update profile when user click on the ok button
'
,
async
()
=>
{
isFirstConnection
:
false
,
await
userEvent
.
click
(
screen
.
getAllByRole
(
'
button
'
)[
1
])
onboarding
:
{
expect
(
mockSendMail
).
toHaveBeenCalled
()
isWelcomeSeen
:
true
,
expect
(
updateProfileSpy
).
toHaveBeenCalledWith
({
},
isFirstConnection
:
false
,
onboarding
:
{
isWelcomeSeen
:
true
,
},
})
})
})
})
it
(
'
should send mail and update profile when modal is closed by user
'
,
async
()
=>
{
it
(
'
should send mail and update profile when modal is closed by user
'
,
async
()
=>
{
const
component
=
mount
(
await
userEvent
.
click
(
screen
.
getAllByRole
(
'
button
'
)[
0
])
<
Provider
store
=
{
store
}
>
expect
(
mockSendMail
).
toHaveBeenCalled
()
<
WelcomeModal
open
=
{
true
}
/>
expect
(
updateProfileSpy
).
toHaveBeenCalledWith
({
</
Provider
>
isFirstConnection
:
false
,
)
onboarding
:
{
component
.
find
(
IconButton
).
first
().
simulate
(
'
click
'
)
isWelcomeSeen
:
true
,
expect
(
mockSendMail
).
toHaveBeenCalled
()
},
expect
(
updateProfileSpy
).
toHaveBeenCalledWith
({
})
isFirstConnection
:
false
,
onboarding
:
{
isWelcomeSeen
:
true
,
},
})
})
})
})
})
})
This diff is collapsed.
Click to expand it.
src/components/WelcomeModal/__snapshots__/WelcomeModal.spec.tsx.snap
+
105
−
1399
View file @
0374df5e
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