-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#498 done; added custom visibility ranges
- Loading branch information
1 parent
bfaa8e6
commit 4d7e5a4
Showing
3 changed files
with
110 additions
and
3 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
54 changes: 54 additions & 0 deletions
54
superfields/src/test/java/org/vaadin/miki/superfields/lazyload/LazyLoadTest.java
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,54 @@ | ||
package org.vaadin.miki.superfields.lazyload; | ||
|
||
import com.github.mvysny.kaributesting.v10.MockVaadin; | ||
import com.vaadin.flow.component.html.Span; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author miki | ||
* @since 2023-12-15 | ||
*/ | ||
public class LazyLoadTest { | ||
|
||
private LazyLoad<Span> lazyLoad; | ||
|
||
@Before | ||
public void setup() { | ||
MockVaadin.setup(); | ||
this.lazyLoad = new LazyLoad<>(new Span("this is a test")); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
MockVaadin.tearDown(); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testVisibilityBelowZero() { | ||
this.lazyLoad.setContentVisibilityRanges(-3, 0.5); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testVisibilityAboveOne() { | ||
this.lazyLoad.setContentVisibilityRanges(0.1, 1.5); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testVisibilityNotInOrder() { | ||
this.lazyLoad.setContentVisibilityRanges(0.9, 0.8); | ||
} | ||
|
||
@Test | ||
public void testVisibilityRangesOk() { | ||
Assert.assertEquals(0, this.lazyLoad.getContentHiddenVisibilityRange(), 0.000005); | ||
Assert.assertEquals(1, this.lazyLoad.getContentShownVisibilityRange(), 0.000005); | ||
|
||
this.lazyLoad.setContentVisibilityRanges(0.2, 0.75); | ||
Assert.assertEquals(0.2, this.lazyLoad.getContentHiddenVisibilityRange(), 0.0005); | ||
Assert.assertEquals(0.75, this.lazyLoad.getContentShownVisibilityRange(), 0.0005); | ||
} | ||
|
||
} |