Skip to content

Commit a78a612

Browse files
committed
Misc: Add isEmpty to TestableStyleProp
1 parent 41744d0 commit a78a612

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/scala/com/raquo/domtestutils/matching/TestableStyleProp.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class TestableStyleProp[V](val name: String) {
1313
testNode.addCheck(nodeStyleIs(expectedValue.toString))
1414
}
1515

16+
def isEmpty: Rule = (testNode: ExpectedNode) => {
17+
// #TODO[Integrity] Not 100% sure that this is reliable, but as far as I can tell, should work with our `getStyle` funciton.
18+
testNode.addCheck(nodeStyleIs(""))
19+
}
20+
1621
private[domtestutils] def nodeStyleIs(expectedValue: String)(node: dom.Node): MaybeError = {
1722
val actualValue = getStyle(node)
1823

@@ -46,7 +51,7 @@ class TestableStyleProp[V](val name: String) {
4651
.selectDynamic("style")
4752
.asInstanceOf[js.UndefOr[CSSStyleDeclaration]]
4853
.flatMap { css =>
49-
css.getPropertyValue(name)
54+
css.getPropertyValue(name) // if not set, returns empty string
5055
}
5156
.toOption
5257
.getOrElse("")

0 commit comments

Comments
 (0)