-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Modal): add/remove dimmer classes in raf (#2010)
* fix(Modal): add/remove dimmer classes in raf * test(Modal): abstract assertBodyContains * fix(Modal): add/remove dimmer classes properly
- Loading branch information
1 parent
5a37f28
commit 9c97ed9
Showing
4 changed files
with
50 additions
and
43 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,22 @@ | ||
/** | ||
* Assert whether or not the document.body has the specified HTML classes. | ||
* | ||
* @param {string|string[]} classes An array of strings string of HTML classes | ||
* @param {boolean} [hasClasses=true] Indicating whether to assert "has" or "does not have" classes | ||
*/ | ||
const assertBodyClasses = (classes, hasClasses = true) => { | ||
const classesArr = [].concat(classes).join(' ').split(' ') | ||
|
||
classesArr.forEach((className) => { | ||
const didFind = document.body.classList.contains(className) | ||
|
||
const message = [ | ||
`document.body should ${hasClasses ? 'have' : 'not have'} class "${className}",`, | ||
`but it ${didFind ? 'has' : 'does not have'} class="${document.body.classList}"`, | ||
].join(' ') | ||
|
||
didFind.should.equal(hasClasses, message) | ||
}) | ||
} | ||
|
||
export default assertBodyClasses |
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