Skip to content

Commit

Permalink
add documentation tests about separate blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Mar 7, 2020
1 parent 5b9f8d3 commit 2b75edf
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,52 @@ class OpeningHoursModelCreatorTest {
assertEquals(expected, actual)
}

@Test fun `does not merge opening weekdays rows of same day when separated by another day`() {
// deliberate, see https://github.com/westnordost/StreetComplete/pull/1676#issuecomment-596017148
val actual = create(
OpeningWeekdaysRow(monday, morning),
OpeningWeekdaysRow(tuesday, morning),
OpeningWeekdaysRow(monday, afternoon)
)

val expected = months(OpeningMonths(wholeYear, clusters(
weekdays(OpeningWeekdays(monday, times(morning))),
weekdays(OpeningWeekdays(tuesday, times(morning))),
weekdays(OpeningWeekdays(monday, times(afternoon)))
)))

assertEquals(expected, actual)
}

@Test fun `does merge overlapping opening weekdays rows of same day is separated by another day`() {
val actual = create(
OpeningWeekdaysRow(monday, morning),
OpeningWeekdaysRow(monday, midday)
)

val expected = months(OpeningMonths(wholeYear, clusters(
weekdays(OpeningWeekdays(monday, times(morning, midday)))
)))
assertEquals(expected, actual)
}

@Test fun `does not merge overlapping opening weekdays rows of same day is separated by another day`() {
// deliberate, see https://github.com/westnordost/StreetComplete/pull/1676#issuecomment-596017148
val actual = create(
OpeningWeekdaysRow(monday, morning),
OpeningWeekdaysRow(tuesday, morning),
OpeningWeekdaysRow(monday, midday)
)

val expected = months(OpeningMonths(wholeYear, clusters(
weekdays(OpeningWeekdays(monday, times(morning))),
weekdays(OpeningWeekdays(tuesday, times(morning))),
weekdays(OpeningWeekdays(monday, times(midday)))
)))

assertEquals(expected, actual)
}

@Test fun `does not cluster different weekdays`() {
val actual = create(
OpeningWeekdaysRow(monday, morning),
Expand Down

0 comments on commit 2b75edf

Please sign in to comment.