18
18
19
19
import com .google .common .base .Predicate ;
20
20
import io .github .seleniumquery .SeleniumQueryObject ;
21
+ import org .hamcrest .collection .IsEmptyCollection ;
21
22
import org .junit .Test ;
22
23
import org .openqa .selenium .WebElement ;
23
24
24
25
import static org .hamcrest .CoreMatchers .is ;
26
+ import static org .hamcrest .collection .IsEmptyCollection .empty ;
25
27
import static org .hamcrest .collection .IsIterableContainingInAnyOrder .containsInAnyOrder ;
26
28
import static org .hamcrest .collection .IsIterableContainingInOrder .contains ;
27
29
import static org .junit .Assert .assertThat ;
28
30
import static testinfrastructure .testdouble .Dummies .createDummyWebElement ;
29
31
import static testinfrastructure .testdouble .SeleniumQueryObjectMother .createStubSeleniumQueryObject ;
32
+ import static testinfrastructure .testdouble .SeleniumQueryObjectMother .createStubSeleniumQueryObjectWithAtLeastOneElement ;
30
33
import static testinfrastructure .testdouble .SeleniumQueryObjectMother .createStubSeleniumQueryObjectWithElements ;
31
34
import static testinfrastructure .testdouble .Stubs .createStubWebElementWithTag ;
32
35
@@ -37,15 +40,13 @@ public class FilterFunctionTest {
37
40
FilterFunction filterFunction = new FilterFunction ();
38
41
39
42
@ Test
40
- public void null_predicate__should_return_same_elements () {
43
+ public void null_predicate__should_return_EMPTY_elements () {
41
44
// given
42
- WebElement dummyWebElement = createDummyWebElement ();
43
- WebElement dummyWebElement2 = createDummyWebElement ();
44
- SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithElements (dummyWebElement , dummyWebElement2 );
45
+ SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithAtLeastOneElement ();
45
46
// when
46
47
SeleniumQueryObject resultSQO = filterFunction .filter (targetSQO , NULL_PREDICATE );
47
48
// then
48
- assertThat (resultSQO .get (), containsInAnyOrder ( dummyWebElement , dummyWebElement2 ));
49
+ assertThat (resultSQO .get (), empty ( ));
49
50
}
50
51
51
52
@ Test
@@ -98,8 +99,4 @@ public boolean apply(WebElement webElement) {
98
99
assertThat (resultSQO .get (), contains (spanOne , spanTwo ));
99
100
}
100
101
101
- // TODO filter(this, null) --> should return empty ==> CHANGE THIS FOR THE PREDICATE VERSION ALSO, it is returning the original matched set
102
- // TODO filter(this, "") --> should return empty
103
- // TODO filter(this, "selector") --> should keep everyone that matches the isFunction("selector")
104
-
105
102
}
0 commit comments