-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c93b802
commit c574a36
Showing
4 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { expect } from "chai"; | ||
import { appendScript, getSample } from "./index.spec"; | ||
import { makeStacksButtonGroup, GroupButton } from "../src/button-groups"; | ||
import { makeStacksButton } from "../src/buttons"; | ||
import { JSDOM } from "jsdom"; | ||
|
||
describe("Button groups", function() { | ||
const buttonGroups = getSample(this.title.toLowerCase().replace(" ", "-")); | ||
|
||
let window: JSDOM["window"]; | ||
|
||
beforeEach(() => { | ||
window = new JSDOM("", { runScripts: "dangerously" }).window; | ||
appendScript(window, { makeStacksButtonGroup, makeStacksButton, Buttons: "{ makeStacksButton }" }); | ||
}); | ||
|
||
it("should correctly generate button groups", () => { | ||
const group = window.makeStacksButtonGroup as typeof makeStacksButtonGroup; | ||
|
||
( | ||
[ | ||
[ | ||
{ text: "Newest" }, | ||
{ text: "Frequent" }, | ||
{ text: "Votes", form: true, selected: true }, | ||
{ text: "Active" }, | ||
{ text: "Unanswered", form: true }, | ||
], | ||
[ | ||
{ text: "Active", count: 197 }, | ||
{ text: "Inactive", count: 37, types: [ "dropdown" ], selected: true }, | ||
{ text: "All", count: 234 } | ||
] | ||
] as GroupButton[][] | ||
).forEach((data, index) => { | ||
const el = group(data); | ||
|
||
expect(el.outerHTML).to.equal(buttonGroups[index].outerHTML); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div class="s-btn-group"><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="Newest">Newest</button><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="Frequent">Frequent</button><form><button class="s-btn s-btn__muted s-btn__outlined is-selected" type="button" role="button" aria-label="Votes">Votes</button></form><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="Active">Active</button><form><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="Unanswered">Unanswered</button></form></div> | ||
<div class="s-btn-group"><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="Active">Active <span class="s-btn--badge"><span class="s-btn--number">197</span></span></button><button class="s-btn s-btn__muted s-btn__outlined s-btn__dropdown is-selected" type="button" role="button" aria-label="Inactive">Inactive <span class="s-btn--badge"><span class="s-btn--number">37</span></span></button><button class="s-btn s-btn__muted s-btn__outlined" type="button" role="button" aria-label="All">All <span class="s-btn--badge"><span class="s-btn--number">234</span></span></button></div> |