@Test public void whenIsOrElseOnAttributes() { final BooleanProperty b = booleanProperty("b", false); final StubElement e = new StubElement(); binder.when(b).is(true).setOrElse("c", "d").onAttribute(e, "foo"); assertThat(e.getAttribute("foo"), is("d")); b.set(true); assertThat(e.getAttribute("foo"), is("c")); }
@Test public void whenIsOrElse() { final BooleanProperty b = booleanProperty("b", false); final StubWidget w = new StubWidget(); binder.when(b).is(true).setOrElse("c", "d").on(w); assertThat(w, hasStyle("d")); assertThat(w, not(hasStyle("c"))); b.set(true); assertThat(w, hasStyle("c")); assertThat(w, not(hasStyle("d"))); }
@Test public void whenIsAnyOf() { final IntegerProperty i = integerProperty("i"); final StubWidget w = new StubWidget(); binder.when(i).isAnyOf(1, 2, 3).setOrElse("c", "d").on(w); assertThat(w, hasStyle("d")); assertThat(w, not(hasStyle("c"))); i.set(1); assertThat(w, hasStyle("c")); assertThat(w, not(hasStyle("d"))); i.set(4); assertThat(w, hasStyle("d")); assertThat(w, not(hasStyle("c"))); i.set(3); assertThat(w, hasStyle("c")); assertThat(w, not(hasStyle("d"))); }