Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot test for #3519 #3520

Merged
merged 6 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Collate:
'version_selectize.R'
'version_strftime.R'
'viewer.R'
Remotes: rstudio/bslib
RoxygenNote: 7.1.2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
35 changes: 35 additions & 0 deletions tests/testthat/_snaps/tabPanel.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,41 @@
<div class="content-footer"></div>
</div>

---

Code
dropdown_active
Output
<div class="tabbable">
<ul class="nav nav-tabs" data-tabsetid="4785">
<li>
<a href="#tab-4785-1" data-toggle="tab" data-bs-toggle="tab" data-value="A">A</a>
</li>
<li>
<a href="#tab-4785-2" data-toggle="tab" data-bs-toggle="tab" data-value="B">
<i aria-label="github icon" class="fab fa-github fa-fw" role="presentation"></i>
B
</a>
</li>
<li class="dropdown active">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the change in rstudio/bslib#372, this .dropdown container was missing the .active class

<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-bs-toggle="dropdown" data-value="Menu">
Menu
<b class="caret"></b>
</a>
<ul class="dropdown-menu" data-tabsetid="1502">
<li class="active">
<a href="#tab-1502-1" data-toggle="tab" data-bs-toggle="tab" data-value="C">C</a>
</li>
</ul>
</li>
</ul>
<div class="tab-content" data-tabsetid="4785">
<div class="tab-pane" data-value="A" id="tab-4785-1">a</div>
<div class="tab-pane" data-value="B" data-icon-class="fab fa-github fa-fw" id="tab-4785-2">b</div>
<div class="tab-pane active" data-value="C" id="tab-1502-1">c</div>
</div>
</div>

# navbarPage() markup is correct

Code
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-tabPanel.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ panels <- list(
)

test_that("tabsetPanel() markup is correct", {

default <- tabset_panel(!!!panels)
pills <- tabset_panel(
!!!panels, type = "pills", selected = "B",
Expand All @@ -54,6 +53,11 @@ test_that("tabsetPanel() markup is correct", {
# BS4
expect_snapshot_bslib(default)
expect_snapshot_bslib(pills)

# Make sure .active class gets added to both the .dropdown as well as the
# .dropdown-menu's tab
dropdown_active <- tabset_panel(!!!panels, selected = "C")
expect_snapshot2(dropdown_active)
})

test_that("navbarPage() markup is correct", {
Expand Down