Skip to content

Commit

Permalink
Add snapshot test for #3519 which was fixed via rstudio/bslib#372
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Oct 1, 2021
1 parent c6ae4c0 commit 97d9d42
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
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">
<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

0 comments on commit 97d9d42

Please sign in to comment.