Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Engineering Digital Service
Metabase
Commits
d5c438ac
Unverified
Commit
d5c438ac
authored
4 years ago
by
Nemanja Glumac
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Migrate `EntityMenuItem` test from enzyme to react-testing-library (#13265)
parent
8a6ef93d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/metabase/components/EntityMenuItem.unit.spec.js
+10
-14
10 additions, 14 deletions
...tend/test/metabase/components/EntityMenuItem.unit.spec.js
with
10 additions
and
14 deletions
frontend/test/metabase/components/EntityMenuItem.unit.spec.js
+
10
−
14
View file @
d5c438ac
import
React
from
"
react
"
;
import
{
shallow
,
mount
}
from
"
enzyme
"
;
import
{
Link
}
from
"
react-router
"
;
import
"
@testing-library/jest-dom/extend-expect
"
;
import
{
fireEvent
,
render
,
screen
}
from
"
@testing-library/react
"
;
import
Icon
from
"
metabase/components/Icon
"
;
import
EntityMenuItem
from
"
metabase/components/EntityMenuItem
"
;
describe
(
"
EntityMenuItem
"
,
()
=>
{
it
(
"
should display the proper title and icon
"
,
()
=>
{
const
wrapper
=
shallow
(
render
(
<
EntityMenuItem
title
=
"
A pencil icon
"
icon
=
"
pencil
"
action
=
{()
=>
({})}
/>
,
);
const
icon
=
wrapper
.
find
(
Icon
);
expect
(
icon
.
length
).
toBe
(
1
);
expect
(
icon
.
props
().
name
).
toEqual
(
"
pencil
"
);
screen
.
getByRole
(
"
img
"
,
{
name
:
/pencil icon/i
});
screen
.
getByText
(
"
A pencil icon
"
);
});
describe
(
"
actions and links
"
,
()
=>
{
...
...
@@ -26,22 +22,22 @@ describe("EntityMenuItem", () => {
it
(
"
should call an action function if an action is provided
"
,
()
=>
{
const
spy
=
jest
.
fn
();
const
wrapper
=
mount
(
render
(
<
EntityMenuItem
title
=
"
A pencil icon
"
icon
=
"
pencil
"
action
=
{
spy
}
/>
,
);
wrapper
.
simulate
(
"
click
"
);
expect
(
spy
).
toHaveBeenCalled
(
);
fireEvent
.
click
(
screen
.
getByRole
(
"
img
"
,
{
name
:
/pencil icon/i
})
);
expect
(
spy
).
toHaveBeenCalled
Times
(
1
);
});
});
describe
(
"
links
"
,
()
=>
{
it
(
"
should be a link if a link is provided
"
,
()
=>
{
const
wrapper
=
mount
(
const
{
container
}
=
render
(
<
EntityMenuItem
title
=
"
A pencil icon
"
icon
=
"
pencil
"
link
=
"
/derp
"
/>
,
);
expect
(
wrapper
.
find
(
Link
).
length
).
toBe
(
1
);
expect
(
container
.
querySelector
(
"
a
"
)).
toBeInTheDocument
(
);
});
});
});
...
...
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