From 8a0f65015c9f6504311c85a34bc66323273bfacb Mon Sep 17 00:00:00 2001 From: Satyam Ghodasara Date: Thu, 14 Mar 2019 21:28:07 -0400 Subject: [PATCH] Fixed documentation spacing --- README.md | 8 ++--- Source/DarkSkyClient.swift | 4 +-- Tests/DarkSkyClientTests.swift | 56 ++++++++++++++++---------------- Tests/DataBlockTests.swift | 12 +++---- Tests/FlagTests.swift | 6 ++-- Tests/ForecastTests.swift | 18 +++++----- Tests/IconTests.swift | 6 ++-- Tests/LanguageTests.swift | 6 ++-- Tests/PrecipitationTests.swift | 6 ++-- Tests/RequestMetadataTests.swift | 6 ++-- Tests/UnitsTest.swift | 6 ++-- 11 files changed, 67 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index dbe9897..4b4acf9 100644 --- a/README.md +++ b/README.md @@ -86,9 +86,9 @@ With the `DarkSkyClient`, you can make two kinds of requests. The first will get client.getForecast(latitude: myLat, longitude: myLon) { result in switch result { case .success(let currentForecast, let requestMetadata): - // We got the current forecast! + // We got the current forecast! case .failure(let error): - // Uh-oh. We have an error! + // Uh-oh. We have an error! } } ``` @@ -99,9 +99,9 @@ The second kind of request is called a time machine request, and it will get a ` client.getForecast(latitude: myLat, longitude: myLon, time: myTime) { result in switch result { case .success(let forecast, let requestMetadata): - // We got the forecast! + // We got the forecast! case .failure(let error): - // Uh-oh. We have an error! + // Uh-oh. We have an error! } } ``` diff --git a/Source/DarkSkyClient.swift b/Source/DarkSkyClient.swift index 8949277..7ae7a40 100644 --- a/Source/DarkSkyClient.swift +++ b/Source/DarkSkyClient.swift @@ -87,14 +87,14 @@ open class DarkSkyClient : NSObject { } private func buildForecastURL(latitude lat: Double, longitude lon: Double, time: Date?, extendHourly: Bool, excludeFields: [Forecast.Field]) -> URL { - // Build URL path + // Build URL path var urlString = DarkSkyClient.darkSkyURL + apiKey + "/\(lat),\(lon)" if let time = time { let timeString = String(format: "%.0f", time.timeIntervalSince1970) urlString.append(",\(timeString)") } - // Build URL query parameters + // Build URL query parameters var urlBuilder = URLComponents(string: urlString)! var queryItems: [URLQueryItem] = [] if let units = self.units { diff --git a/Tests/DarkSkyClientTests.swift b/Tests/DarkSkyClientTests.swift index 9562fb9..5ff9807 100644 --- a/Tests/DarkSkyClientTests.swift +++ b/Tests/DarkSkyClientTests.swift @@ -23,16 +23,16 @@ class DarkSkyClientTests: XCTestCase { } func testInit() { - // Given - // When + // Given + // When let client = DarkSkyClient(apiKey: apiKey) - // Then + // Then XCTAssertNotNil(client) } func testGetForecast() { - // Given + // Given let expect = expectation(description: "Get forecast") let hostStub = isHost("api.darksky.net") let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)") @@ -47,7 +47,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in switch result { case .success(let currentForecast, let requestMetadata): @@ -59,7 +59,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -71,7 +71,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastAtTime() { - // Given + // Given let expect = expectation(description: "Get forecast at time") let time = Date() let timeString = String(format: "%.0f", time.timeIntervalSince1970) @@ -89,7 +89,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude, time: time) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -101,7 +101,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -113,7 +113,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithSIUnits() { - // Given + // Given let expect = expectation(description: "Get forecast with SI units") let hostStub = isHost("api.darksky.net") let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)") @@ -130,7 +130,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -142,7 +142,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -154,7 +154,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithFrenchLanguage() { - // Given + // Given let expect = expectation(description: "Get forecast with French language") let hostStub = isHost("api.darksky.net") let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)") @@ -171,7 +171,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -183,7 +183,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -195,7 +195,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithExtendedHourly() { - // Given + // Given let expect = expectation(description: "Get forecast wtih extended hourly") let hostStub = isHost("api.darksky.net") let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)") @@ -211,7 +211,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude, extendHourly: true) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -223,7 +223,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -235,7 +235,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithExcludedFields() { - // Given + // Given let expect = expectation(description: "Get forecast wtih excluded forecast fields") let hostStub = isHost("api.darksky.net") let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)") @@ -251,7 +251,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude, excludeFields: [.minutely, .daily]) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -263,7 +263,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -275,7 +275,7 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithoutInternet() { - // Given + // Given let expect = expectation(description: "Get forecast without internet") let notConnectedError = NSError(domain:NSURLErrorDomain, code:Int(CFNetworkErrors.cfurlErrorNotConnectedToInternet.rawValue), userInfo:nil) _ = stub(condition: isHost("api.darksky.net")) { _ in @@ -286,7 +286,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -298,7 +298,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") @@ -310,10 +310,10 @@ class DarkSkyClientTests: XCTestCase { } func testGetForecastWithBadJSON() { - // Given + // Given let expect = expectation(description: "Get forecast with bad JSON") _ = stub(condition: isHost("api.darksky.net")) { _ in - // Return empty body instead of JSON + // Return empty body instead of JSON return fixture(filePath: "", headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) } let client = DarkSkyClient(apiKey: "FAKE-API-KEY") @@ -321,7 +321,7 @@ class DarkSkyClientTests: XCTestCase { var metadata: RequestMetadata? var err: Error? - // When + // When client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in switch result { case .success(let aForecast, let requestMetadata): @@ -333,7 +333,7 @@ class DarkSkyClientTests: XCTestCase { expect.fulfill() } - // Then + // Then waitForExpectations(timeout: 5, handler: { error in if let error = error { print("Error: \(error.localizedDescription)") diff --git a/Tests/DataBlockTests.swift b/Tests/DataBlockTests.swift index 7b17172..81d9bf4 100644 --- a/Tests/DataBlockTests.swift +++ b/Tests/DataBlockTests.swift @@ -36,11 +36,11 @@ class DataBlockTests: XCTestCase { } func testInitFromDecoder() { - // Given - // When + // Given + // When let dataBlock = try! self.decoder.decode(DataBlock.self, from: self.dataBlockJSONData) - // Then + // Then XCTAssertNotNil(dataBlock) XCTAssertEqual(dataBlock.summary, "Snow for the hour.") XCTAssertEqual(dataBlock.icon, Icon.snow) @@ -48,11 +48,11 @@ class DataBlockTests: XCTestCase { } func testInitFromDecoderNoOptionals() { - // Given - // When + // Given + // When let dataBlock = try! self.decoder.decode(DataBlock.self, from: self.dataBlockNoOptionalsJSONData) - // Then + // Then XCTAssertNotNil(dataBlock) XCTAssertNil(dataBlock.summary) XCTAssertNil(dataBlock.icon) diff --git a/Tests/FlagTests.swift b/Tests/FlagTests.swift index 75841da..131765e 100644 --- a/Tests/FlagTests.swift +++ b/Tests/FlagTests.swift @@ -31,11 +31,11 @@ class FlagTests: XCTestCase { } func testInitFromDecoder() { - // Given - // When + // Given + // When let flag = try! self.decoder.decode(Flag.self, from: self.flagJSONData) - // Then + // Then XCTAssertNotNil(flag) XCTAssertNil(flag.darkSkyUnavailable) XCTAssertEqual(flag.darkSkyStations, ["KLWX", "KDOX"]) diff --git a/Tests/ForecastTests.swift b/Tests/ForecastTests.swift index 35e8232..66487d2 100644 --- a/Tests/ForecastTests.swift +++ b/Tests/ForecastTests.swift @@ -36,11 +36,11 @@ class ForecastTests: XCTestCase { } func testInitFromDecoder() { - // Given - // When + // Given + // When let forecast = try! self.decoder.decode(Forecast.self, from: self.forecastJSONData) - // Then + // Then XCTAssertNotNil(forecast) XCTAssertEqual(forecast.latitude, 39.290385) XCTAssertEqual(forecast.longitude, -76.612189) @@ -52,11 +52,11 @@ class ForecastTests: XCTestCase { } func testInitFromDecoderBare() { - // Given - // When + // Given + // When let forecast = try! self.decoder.decode(Forecast.self, from: self.forecastBareJSONData) - // Then + // Then XCTAssertNotNil(forecast) XCTAssertEqual(forecast.latitude, 39.290385) XCTAssertEqual(forecast.longitude, -76.612189) @@ -68,9 +68,9 @@ class ForecastTests: XCTestCase { } func testFieldRawValue() { - // Given - // When - // Then + // Given + // When + // Then XCTAssertEqual(Forecast.Field.currently.rawValue, "currently") XCTAssertEqual(Forecast.Field.minutely.rawValue, "minutely") XCTAssertEqual(Forecast.Field.hourly.rawValue, "hourly") diff --git a/Tests/IconTests.swift b/Tests/IconTests.swift index ceb7b0f..f7c8241 100644 --- a/Tests/IconTests.swift +++ b/Tests/IconTests.swift @@ -12,9 +12,9 @@ import XCTest class IconTests: XCTestCase { func testRawValue() { - // Given - // When - // Then + // Given + // When + // Then XCTAssertEqual(Icon.clearDay.rawValue, "clear-day") XCTAssertEqual(Icon.clearNight.rawValue, "clear-night") XCTAssertEqual(Icon.rain.rawValue, "rain") diff --git a/Tests/LanguageTests.swift b/Tests/LanguageTests.swift index cfb32c6..19be55a 100644 --- a/Tests/LanguageTests.swift +++ b/Tests/LanguageTests.swift @@ -12,9 +12,9 @@ import XCTest class LanguageTests: XCTestCase { func testRawValue() { - // Given - // When - // Then + // Given + // When + // Then XCTAssertEqual(Language.arabic.rawValue, "ar") XCTAssertEqual(Language.azerbaijani.rawValue, "az") XCTAssertEqual(Language.belarusian.rawValue, "be") diff --git a/Tests/PrecipitationTests.swift b/Tests/PrecipitationTests.swift index d036bf7..affd5e1 100644 --- a/Tests/PrecipitationTests.swift +++ b/Tests/PrecipitationTests.swift @@ -12,9 +12,9 @@ import XCTest class PrecipitationTests: XCTestCase { func testDescription() { - // Given - // When - // Then + // Given + // When + // Then XCTAssertEqual(Precipitation.rain.rawValue, "rain") XCTAssertEqual(Precipitation.snow.rawValue, "snow") XCTAssertEqual(Precipitation.sleet.rawValue, "sleet") diff --git a/Tests/RequestMetadataTests.swift b/Tests/RequestMetadataTests.swift index e46e987..482ee08 100644 --- a/Tests/RequestMetadataTests.swift +++ b/Tests/RequestMetadataTests.swift @@ -12,13 +12,13 @@ import XCTest class RequestMetadataTests: XCTestCase { func testInitFromHTTPHeaderFields() { - // Given + // Given let httpHeaderFields = ["Cache-Control": "max-age=60", "x-forecast-api-calls": "12", "x-response-time": "123.45ms"] - // When + // When let requestMetadata = RequestMetadata(fromHTTPHeaderFields: httpHeaderFields) - // Then + // Then XCTAssertNotNil(requestMetadata) XCTAssertEqual(requestMetadata.cacheControl, "max-age=60") XCTAssertEqual(requestMetadata.apiRequestsCount, 12) diff --git a/Tests/UnitsTest.swift b/Tests/UnitsTest.swift index d0ca338..d799d0d 100644 --- a/Tests/UnitsTest.swift +++ b/Tests/UnitsTest.swift @@ -12,9 +12,9 @@ import XCTest class UnitsTests: XCTestCase { func testDescription() { - // Given - // When - // Then + // Given + // When + // Then XCTAssertEqual(Units.si.rawValue, "si") XCTAssertEqual(Units.us.rawValue, "us") XCTAssertEqual(Units.ca.rawValue, "ca")