-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ox.flow | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import ox.* | ||
|
||
class FlowOpsDebounceByTest extends AnyFlatSpec with Matchers: | ||
behavior of "debounceBy" | ||
|
||
it should "not debounce if applied on an empty flow" in: | ||
val c = Flow.empty[Int] | ||
val s = c.debounceBy(_ * 2) | ||
s.runToList() shouldBe List.empty | ||
|
||
it should "not debounce if applied on a flow containing only distinct f(value)" in: | ||
val c = Flow.fromValues(1 to 10: _*) | ||
val s = c.debounceBy(_ * 2) | ||
s.runToList() shouldBe (1 to 10) | ||
|
||
it should "debounce if applied on a flow containing repeating f(value)" in: | ||
val c = Flow.fromValues(1, 1, 2, 3, 4, 4, 5) | ||
val s = c.debounceBy(_ * 2) | ||
s.runToList() shouldBe (1 to 5) | ||
|
||
it should "debounce subsequent odd/prime numbers" in: | ||
val c = Flow.fromValues(1, 1, 1, 2, 4, 3, 7, 4, 5) | ||
val s = c.debounceBy(_ % 2 == 0) | ||
s.runToList() shouldBe List(1, 2, 3, 4, 5) | ||
|
||
end FlowOpsDebounceByTest |
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,30 @@ | ||
package ox.flow | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import ox.* | ||
|
||
class FlowOpsDebounceTest extends AnyFlatSpec with Matchers: | ||
behavior of "debounce" | ||
|
||
it should "not debounce if applied on an empty flow" in: | ||
val c = Flow.empty[Int] | ||
val s = c.debounce | ||
s.runToList() shouldBe List.empty | ||
|
||
it should "not debounce if applied on a flow containing only distinct values" in: | ||
val c = Flow.fromValues(1 to 10: _*) | ||
val s = c.debounce | ||
s.runToList() shouldBe (1 to 10) | ||
|
||
it should "debounce if applied on a flow containing only repeating values" in: | ||
val c = Flow.fromValues(1, 1, 1, 1, 1) | ||
val s = c.debounce | ||
s.runToList() shouldBe List(1) | ||
|
||
it should "debounce if applied on a flow containing repeating elements" in: | ||
val c = Flow.fromValues(1, 1, 2, 3, 4, 4, 5) | ||
val s = c.debounce | ||
s.runToList() shouldBe (1 to 5) | ||
|
||
end FlowOpsDebounceTest |