Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed May 7, 2024
1 parent b641480 commit d261ecd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import roguelikestarterkit.ui.component.ComponentLayout.Horizontal

class ComponentGroupTests extends munit.FunSuite {

given Component[String] = new Component[String] {
given Component[String, Unit] = new Component[String, Unit] {
def bounds(model: String): Bounds = Bounds(0, 0, model.length, 1)

def updateModel[Unit](
def updateModel(
context: UiContext[Unit],
model: String
): GlobalEvent => Outcome[String] =
_ => Outcome(model)

def present[Unit](
def present(
context: UiContext[Unit],
model: String
): Outcome[ComponentFragment] =
Expand All @@ -31,8 +31,8 @@ class ComponentGroupTests extends munit.FunSuite {
}

test("reflow should reapply the layout to all existing components") {
val component1 = ComponentEntry(Coords(0, 0), "abc", summon[Component[String]])
val component2 = ComponentEntry(Coords(10, 10), "def", summon[Component[String]])
val component1 = ComponentEntry(Coords(0, 0), "abc", summon[Component[String, Unit]])
val component2 = ComponentEntry(Coords(10, 10), "def", summon[Component[String, Unit]])
val group = ComponentGroup(
Bounds(0, 0, 100, 100),
BoundsType.Fixed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class WindowModelTests extends munit.FunSuite:
FontKey("test")
)

val component = ComponentEntry(Coords(0, 0), "abc", summon[Component[String]])
val group = ComponentGroup(
val component = ComponentEntry[String, Unit](Coords(0, 0), "abc", summon[Component[String, Unit]])
val group = ComponentGroup[Unit](
Bounds(0, 0, 100, 100),
BoundsType.Fixed,
ComponentLayout.Horizontal(Padding(5), Overflow.Wrap),
Batch(component)
)

test("model cascades bounds changes to component group - BoundsType.Fixed") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -73,7 +73,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.Inherit") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -84,7 +84,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.Relative") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -95,7 +95,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.Relative 100%") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -106,7 +106,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.RelativePosition") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -117,7 +117,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.RelativeSize") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -128,7 +128,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.Offset") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -139,7 +139,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.OffsetPosition") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -150,7 +150,7 @@ class WindowModelTests extends munit.FunSuite:
}

test("model cascades bounds changes to component group - BoundsType.OffsetSize") {
val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -173,7 +173,7 @@ class WindowModelTests extends munit.FunSuite:
.add(Bounds(0, 0, 0, 0))
)

val model: WindowModel[ComponentGroup, Unit] =
val model: WindowModel[ComponentGroup[Unit], Unit] =
WindowModel(
WindowId("test"),
charSheet,
Expand All @@ -188,7 +188,7 @@ class WindowModelTests extends munit.FunSuite:
fail("No sub components found")

case Some(value) =>
val cg = value.model.asInstanceOf[ComponentGroup]
val cg = value.model.asInstanceOf[ComponentGroup[Unit]]

// top comp group cascades to next level.
assertEquals(cg.bounds, Bounds(3, 5, 36, 34))
Expand All @@ -205,16 +205,16 @@ class WindowModelTests extends munit.FunSuite:

}

given Component[String] = new Component[String] {
given Component[String, Unit] = new Component[String, Unit] {
def bounds(model: String): Bounds = Bounds(0, 0, model.length, 1)

def updateModel[Unit](
def updateModel(
context: UiContext[Unit],
model: String
): GlobalEvent => Outcome[String] =
_ => Outcome(model)

def present[Unit](
def present(
context: UiContext[Unit],
model: String
): Outcome[ComponentFragment] =
Expand All @@ -227,16 +227,16 @@ class WindowModelTests extends munit.FunSuite:
model
}

given Component[Bounds] = new Component[Bounds] {
given Component[Bounds, Unit] = new Component[Bounds, Unit] {
def bounds(model: Bounds): Bounds = model

def updateModel[Unit](
def updateModel(
context: UiContext[Unit],
model: Bounds
): GlobalEvent => Outcome[Bounds] =
_ => Outcome(model)

def present[Unit](
def present(
context: UiContext[Unit],
model: Bounds
): Outcome[ComponentFragment] =
Expand Down

0 comments on commit d261ecd

Please sign in to comment.