From 2b75edf76dc49a65e6892e3fc1e169ecdc3f932b Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Sat, 7 Mar 2020 13:04:54 +0100 Subject: [PATCH] add documentation tests about separate blocks --- .../adapter/OpeningHoursModelCreatorTest.kt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/src/test/java/de/westnordost/streetcomplete/quests/opening_hours/adapter/OpeningHoursModelCreatorTest.kt b/app/src/test/java/de/westnordost/streetcomplete/quests/opening_hours/adapter/OpeningHoursModelCreatorTest.kt index 243e5bfbfdb..d00ca789a25 100644 --- a/app/src/test/java/de/westnordost/streetcomplete/quests/opening_hours/adapter/OpeningHoursModelCreatorTest.kt +++ b/app/src/test/java/de/westnordost/streetcomplete/quests/opening_hours/adapter/OpeningHoursModelCreatorTest.kt @@ -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),