diff --git a/src/main/scala/com.github.mgifos.workouts/model/Target.scala b/src/main/scala/com.github.mgifos.workouts/model/Target.scala index 811df83..bcf3d33 100644 --- a/src/main/scala/com.github.mgifos.workouts/model/Target.scala +++ b/src/main/scala/com.github.mgifos.workouts/model/Target.scala @@ -104,9 +104,9 @@ object Target { def parse(x: String)(implicit msys: MeasurementSystems.MeasurementSystem): Target = x.trim match { case CadenceCustomRx(from, to) => CadenceCustomTarget(from.toInt, to.toInt) - case HrZoneRx(zone) => HrZoneTarget(zone.toInt) - case HrCustomRx(from, to) => HrCustomTarget(from.toInt, to.toInt) - case PowerCustomRx(from, to) => PowerCustomTarget(from.toInt, to.toInt) + case HrZoneRx(zone) => HrZoneTarget(zone.toInt) + case HrCustomRx(from, to) => HrCustomTarget(from.toInt, to.toInt) + case PowerCustomRx(from, to) => PowerCustomTarget(from.toInt, to.toInt) case SpeedRangeRx(from, _, to, _, uom) => val du = Option(uom).fold(msys.distance)(DistanceUnits.withSpeedUOM) SpeedTarget(Speed(du, from), Speed(du, to)) diff --git a/src/test/scala/com/github/mgifos/workouts/WeekPlanSpec.scala b/src/test/scala/com/github/mgifos/workouts/WeekPlanSpec.scala index c7d69c9..641da89 100644 --- a/src/test/scala/com/github/mgifos/workouts/WeekPlanSpec.scala +++ b/src/test/scala/com/github/mgifos/workouts/WeekPlanSpec.scala @@ -1,7 +1,7 @@ package com.github.mgifos.workouts import com.github.mgifos.workouts.model._ -import org.scalatest.{ FlatSpec, Matchers } +import org.scalatest.{FlatSpec, Matchers} class WeekPlanSpec extends FlatSpec with Matchers { diff --git a/src/test/scala/com/github/mgifos/workouts/model/DurationSpec.scala b/src/test/scala/com/github/mgifos/workouts/model/DurationSpec.scala index 6c609f9..3e4022e 100644 --- a/src/test/scala/com/github/mgifos/workouts/model/DurationSpec.scala +++ b/src/test/scala/com/github/mgifos/workouts/model/DurationSpec.scala @@ -1,6 +1,6 @@ package com.github.mgifos.workouts.model -import org.scalatest.{ FlatSpec, Matchers } +import org.scalatest.{FlatSpec, Matchers} import com.github.mgifos.workouts.model.DistanceUnits._ class DurationSpec extends FlatSpec with Matchers { diff --git a/src/test/scala/com/github/mgifos/workouts/model/StepSpec.scala b/src/test/scala/com/github/mgifos/workouts/model/StepSpec.scala index 078daea..f802b23 100644 --- a/src/test/scala/com/github/mgifos/workouts/model/StepSpec.scala +++ b/src/test/scala/com/github/mgifos/workouts/model/StepSpec.scala @@ -1,7 +1,7 @@ package com.github.mgifos.workouts.model import com.github.mgifos.workouts.model.DistanceUnits._ -import org.scalatest.{ FlatSpec, Matchers } +import org.scalatest.{FlatSpec, Matchers} class StepSpec extends FlatSpec with Matchers { @@ -13,13 +13,15 @@ class StepSpec extends FlatSpec with Matchers { a[IllegalArgumentException] should be thrownBy Step.parse("- warmup: 5km\n - run: 10km\n - recover: 100m") Step.parse("- warmup: 5km") should be(WarmupStep(DistanceDuration(5, km))) - Step.parse("- run: 2km @ 5:00-4:50") should be(IntervalStep(DistanceDuration(2, km), Some(PaceTarget(Pace(msys.distance, "5:00"), Pace(msys.distance, "4:50"))))) - Step.parse("- bike: 2km @ 20-30 kph") should be(IntervalStep(DistanceDuration(2, km), Some(SpeedTarget(Speed(msys.distance, "20"), Speed(msys.distance, "30"))))) - Step.parse("- go: 20km @ 9:00-11:00") should be(IntervalStep(DistanceDuration(20, km), Some(PaceTarget(Pace(msys.distance, "9:00"), Pace(msys.distance, "11:00"))))) + Step.parse("- run: 2km @ 5:00-4:50") should be( + IntervalStep(DistanceDuration(2, km), Some(PaceTarget(Pace(msys.distance, "5:00"), Pace(msys.distance, "4:50"))))) + Step.parse("- bike: 2km @ 20-30 kph") should be( + IntervalStep(DistanceDuration(2, km), Some(SpeedTarget(Speed(msys.distance, "20"), Speed(msys.distance, "30"))))) + Step.parse("- go: 20km @ 9:00-11:00") should be( + IntervalStep(DistanceDuration(20, km), Some(PaceTarget(Pace(msys.distance, "9:00"), Pace(msys.distance, "11:00"))))) Step.parse("- recover: 500m @z2") should be(RecoverStep(DistanceDuration(500, m), Some(HrZoneTarget(2)))) Step.parse("- cooldown: 05:00") should be(CooldownStep(TimeDuration(minutes = 5))) - Step.parse("- repeat: 3\n - run: 10km\n - recover: 100m") should be(RepeatStep(3, List( - IntervalStep(DistanceDuration(10, km)), - RecoverStep(DistanceDuration(100, m))))) + Step.parse("- repeat: 3\n - run: 10km\n - recover: 100m") should be( + RepeatStep(3, List(IntervalStep(DistanceDuration(10, km)), RecoverStep(DistanceDuration(100, m))))) } } diff --git a/src/test/scala/com/github/mgifos/workouts/model/TargetSpec.scala b/src/test/scala/com/github/mgifos/workouts/model/TargetSpec.scala index 81198d4..64a549a 100644 --- a/src/test/scala/com/github/mgifos/workouts/model/TargetSpec.scala +++ b/src/test/scala/com/github/mgifos/workouts/model/TargetSpec.scala @@ -1,8 +1,8 @@ package com.github.mgifos.workouts.model -import org.scalatest.{ FlatSpec, Matchers } +import org.scalatest.{FlatSpec, Matchers} import com.github.mgifos.workouts.model.DistanceUnits._ -import play.api.libs.json.{ JsNull, Json } +import play.api.libs.json.{JsNull, Json} class TargetSpec extends FlatSpec with Matchers { @@ -35,36 +35,36 @@ class TargetSpec extends FlatSpec with Matchers { "Target" should "handle custom HR specification correctly" in { val hrcTarget = Target.parse("130-150 bpm").asInstanceOf[HrCustomTarget] hrcTarget should be(HrCustomTarget(130, 150)) - hrcTarget.json should be(Json.obj( - "targetType" -> Json.obj( - "workoutTargetTypeId" -> 4, - "workoutTargetTypeKey" -> "heart.rate.zone"), - "targetValueOne" -> 130, - "targetValueTwo" -> 150, - "zoneNumber" -> JsNull)) + hrcTarget.json should be( + Json.obj( + "targetType" -> Json.obj("workoutTargetTypeId" -> 4, "workoutTargetTypeKey" -> "heart.rate.zone"), + "targetValueOne" -> 130, + "targetValueTwo" -> 150, + "zoneNumber" -> JsNull + )) } "Target" should "handle custom POWER specification correctly" in { val powTarget = Target.parse("230-250 W").asInstanceOf[PowerCustomTarget] powTarget should be(PowerCustomTarget(230, 250)) - powTarget.json should be(Json.obj( - "targetType" -> Json.obj( - "workoutTargetTypeId" -> 2, - "workoutTargetTypeKey" -> "power.zone"), - "targetValueOne" -> 230, - "targetValueTwo" -> 250, - "zoneNumber" -> JsNull)) + powTarget.json should be( + Json.obj( + "targetType" -> Json.obj("workoutTargetTypeId" -> 2, "workoutTargetTypeKey" -> "power.zone"), + "targetValueOne" -> 230, + "targetValueTwo" -> 250, + "zoneNumber" -> JsNull + )) } - + "Target" should "handle custom CADENCE specification correctly" in { val cadenceTarget = Target.parse("80-90 rpm").asInstanceOf[CadenceCustomTarget] cadenceTarget should be(CadenceCustomTarget(80, 90)) - cadenceTarget.json should be(Json.obj( - "targetType" -> Json.obj( - "workoutTargetTypeId" -> 3, - "workoutTargetTypeKey" -> "cadence.zone"), - "targetValueOne" -> 80, - "targetValueTwo" -> 90, - "zoneNumber" -> JsNull)) + cadenceTarget.json should be( + Json.obj( + "targetType" -> Json.obj("workoutTargetTypeId" -> 3, "workoutTargetTypeKey" -> "cadence.zone"), + "targetValueOne" -> 80, + "targetValueTwo" -> 90, + "zoneNumber" -> JsNull + )) } }