Skip to content

Commit

Permalink
Fix for not putting time zone id into result intent
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuy Trinh committed Dec 24, 2016
1 parent 01c6fe4 commit 7194744
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DateTimeRangePickerViewModel(private val timeFormatter: TimeFormatter) {
return Intent()
.putExtra(KEY_START_TIME_IN_MILLIS, startDateTime.value!!.millis)
.putExtra(KEY_END_TIME_IN_MILLIS, endDateTime.value!!.millis)
.putExtra(KEY_TIME_ZONE, timeZone)
.putExtra(KEY_TIME_ZONE, timeZone!!.id)
}

fun updateSelectedDates(selectedDates: List<Date>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,18 @@ class DateTimeRangePickerViewModelTest {
assertThat(viewModel.startDateTime.value!!).isEqualTo(startDateTime)
assertThat(viewModel.endDateTime.value!!).isEqualTo(endDateTime)
}

@Test fun shouldCreateCorrectResultIntent() {
whenever(timeFormatter.printTime(any())).thenReturn("")

val startDateTime = DateTime.now()
val endDateTime = startDateTime.plusDays(1)

viewModel.timeZone = TimeZone.getTimeZone("CET")
viewModel.startDateTime.onNext(startDateTime)
viewModel.endDateTime.onNext(endDateTime)

val resultIntent = viewModel.createResultIntent()
assertThat(resultIntent.getStringExtra("timeZone")).isEqualTo("CET")
}
}

0 comments on commit 7194744

Please sign in to comment.