Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- added test cases
  • Loading branch information
temi committed Sep 11, 2024
1 parent a790cc1 commit 5411a7b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/test/groovy/au/org/ala/merit/SearchServiceSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package au.org.ala.merit

import au.org.ala.merit.hub.HubSettings
import grails.core.GrailsApplication
import grails.testing.spring.AutowiredTest
import org.apache.http.HttpStatus
import org.joda.time.DateTimeZone
import spock.lang.Specification

class SearchServiceSpec extends Specification implements AutowiredTest{
Expand Down Expand Up @@ -80,6 +80,29 @@ class SearchServiceSpec extends Specification implements AutowiredTest{
result == true
}

def "getIsoDateFromClientDate with various timezones"() {
expect: "The correct ISO date is returned for each date and time zone"
service.getIsoDateFromClientDate(clientDate, timeZone) == expectedIsoDate

where:
clientDate | timeZone | expectedIsoDate
"2024-09-10" | DateTimeZone.forID("Australia/Sydney") | "2024-09-09T14:00:00Z"
"2024-09-10" | DateTimeZone.forID("Australia/Perth") | "2024-09-09T16:00:00Z"
"2024-09-10" | DateTimeZone.forID("Australia/Darwin") | "2024-09-09T14:30:00Z"
}

def "getIsoDateFromClientDate throws exception for invalid input"() {
when: "Invalid input is passed to the method"
service.getIsoDateFromClientDate(clientDate, timeZone)

then: "An IllegalArgumentException is thrown"
thrown(IllegalArgumentException)

where: "Different invalid inputs are provided"
clientDate | timeZone
"invalid-date-format" | DateTimeZone.forID("Australia/Sydney")
}

private List stubGeoReponseFromCoordinateList(List coords) {
List results = new ArrayList(coords.size())
coords.each { List coord ->
Expand Down

0 comments on commit 5411a7b

Please sign in to comment.