@@ -8,23 +8,26 @@ import Nimble
88@testable import SwiftWeather
99
1010class ForecastDateTimeSpec : QuickSpec {
11- override func spec( ) {
12- describe ( " #init " ) {
13- it ( " should init with the rawDate correctly assigned " ) {
14- var forecastDateTime = ForecastDateTime ( 1234 )
15- expect ( forecastDateTime. rawDate) . to ( beCloseTo ( 1234 ) )
16- forecastDateTime = ForecastDateTime ( 0 )
17- expect ( forecastDateTime. rawDate) . to ( beCloseTo ( 0 ) )
18- }
11+
12+ private let testTimeZone = TimeZone ( abbreviation: " UTC+11:00 " ) !
13+
14+ override func spec( ) {
15+ describe ( " #init " ) {
16+ it ( " should init with the rawDate correctly assigned " ) {
17+ var forecastDateTime = ForecastDateTime ( date: 1488096060 , timeZone: self . testTimeZone)
18+ expect ( forecastDateTime. rawDate) . to ( beCloseTo ( 1488096060 ) )
19+ forecastDateTime = ForecastDateTime ( date: 0 , timeZone: self . testTimeZone)
20+ expect ( forecastDateTime. rawDate) . to ( beCloseTo ( 0 ) )
21+ }
22+ }
23+
24+ describe ( " #shortTime " ) {
25+ it ( " should return the correct shortTime string with format HH:mm " ) {
26+ var forecastDateTime = ForecastDateTime ( date: 1488096060 , timeZone: self . testTimeZone)
27+ expect ( forecastDateTime. shortTime) . to ( equal ( " 7:01 PM " ) )
28+ forecastDateTime = ForecastDateTime ( date: 1488103200 , timeZone: self . testTimeZone)
29+ expect ( forecastDateTime. shortTime) . to ( equal ( " 9:00 PM " ) )
30+ }
31+ }
1932 }
20-
21- describe ( " #shortTime " ) {
22- it ( " should return the correct shortTime string with format HH:mm " ) {
23- var forecastDateTime = ForecastDateTime ( 1488096060 )
24- expect ( forecastDateTime. shortTime) . to ( equal ( " 01:01 " ) )
25- forecastDateTime = ForecastDateTime ( 1488103200 )
26- expect ( forecastDateTime. shortTime) . to ( equal ( " 03:00 " ) )
27- }
28- }
29- }
3033}
0 commit comments