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
eef49329
Unverified
Commit
eef49329
authored
1 year ago
by
Nemanja Glumac
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Expand the test coverage for `ListItem` component (#30635)
parent
4cd818b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/components/ListItem/ListItem.unit.spec.js
+60
-0
60 additions, 0 deletions
...nd/src/metabase/components/ListItem/ListItem.unit.spec.js
with
60 additions
and
0 deletions
frontend/src/metabase/components/ListItem/ListItem.unit.spec.js
0 → 100644
+
60
−
0
View file @
eef49329
import
React
from
"
react
"
;
import
{
Route
}
from
"
react-router
"
;
import
{
screen
,
getIcon
,
renderWithProviders
}
from
"
__support__/ui
"
;
import
ListItem
from
"
./ListItem
"
;
const
ITEM_NAME
=
"
Table Foo
"
;
const
ITEM_DESCRIPTION
=
"
Nice table description.
"
;
function
setup
({
name
,
index
=
0
,
...
opts
})
{
return
renderWithProviders
(
<
Route
path
=
"
/
"
component
=
{()
=>
<
ListItem
name
=
{
name
}
index
=
{
index
}
{...
opts
}
/>
}
/>
,
{
withRouter
:
true
},
);
}
describe
(
"
ListItem
"
,
()
=>
{
it
(
"
should render
"
,
()
=>
{
setup
({
name
:
ITEM_NAME
,
description
:
ITEM_DESCRIPTION
,
icon
:
"
table
"
,
url
:
"
/foo
"
,
});
expect
(
screen
.
getByText
(
ITEM_NAME
)).
toBeInTheDocument
();
expect
(
screen
.
getByText
(
ITEM_DESCRIPTION
)).
toBeInTheDocument
();
expect
(
getIcon
(
"
table
"
)).
toBeInTheDocument
();
expect
(
screen
.
getByRole
(
"
link
"
)).
toHaveProperty
(
"
href
"
,
"
http://localhost/foo
"
,
);
});
it
(
"
should render with just the name
"
,
()
=>
{
setup
({
name
:
ITEM_NAME
});
expect
(
screen
.
getByText
(
ITEM_NAME
)).
toBeInTheDocument
();
});
it
(
"
should display the placeholder if there's no description
"
,
()
=>
{
setup
({
name
:
ITEM_NAME
,
placeholder
:
"
Placeholder text
"
});
expect
(
screen
.
getByText
(
ITEM_NAME
)).
toBeInTheDocument
();
expect
(
screen
.
getByText
(
"
Placeholder text
"
)).
toBeInTheDocument
();
});
it
(
"
should display the description and omit the placeholder if both are present
"
,
()
=>
{
setup
({
name
:
ITEM_NAME
,
description
:
ITEM_DESCRIPTION
,
placeholder
:
"
Placeholder text
"
,
});
expect
(
screen
.
getByText
(
ITEM_NAME
)).
toBeInTheDocument
();
expect
(
screen
.
getByText
(
ITEM_DESCRIPTION
)).
toBeInTheDocument
();
expect
(
screen
.
queryByText
(
"
Placeholder text
"
)).
not
.
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