From 582c1019b2a8296de7b7c21d806ec93cada44b62 Mon Sep 17 00:00:00 2001 From: Xan Johnson Date: Thu, 26 Oct 2023 16:40:38 -0600 Subject: [PATCH] update unit tests --- .../ClientBuilderTests.swift | 2 + .../URLPrefixSenderTests.swift | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Tests/SmartyStreetsTests/URLPrefixSenderTests.swift diff --git a/Tests/SmartyStreetsTests/ClientBuilderTests.swift b/Tests/SmartyStreetsTests/ClientBuilderTests.swift index a0809be..352f7fc 100644 --- a/Tests/SmartyStreetsTests/ClientBuilderTests.swift +++ b/Tests/SmartyStreetsTests/ClientBuilderTests.swift @@ -22,6 +22,8 @@ class ClientBuilderTests: XCTestCase { XCTAssertEqual(client.maxTimeout, 10000) XCTAssertEqual(client.debug, false) XCTAssertEqual(client.internationalStreetApiURL, "https://international-street.api.smarty.com/verify") + XCTAssertEqual(client.internationalAutocompleteApiURL, "https://international-autocomplete.api.smarty.com/v2/lookup") + XCTAssertEqual(client.internationalAutocompleteApiDeprecatedURL, "https://international-autocomplete.api.smarty.com/lookup") XCTAssertEqual(client.usAutocompleteApiURL, "https://us-autocomplete.api.smarty.com/suggest") XCTAssertEqual(client.usExtractApiURL, "https://us-extract.api.smarty.com") XCTAssertEqual(client.usStreetApiURL, "https://us-street.api.smarty.com/street-address") diff --git a/Tests/SmartyStreetsTests/URLPrefixSenderTests.swift b/Tests/SmartyStreetsTests/URLPrefixSenderTests.swift new file mode 100644 index 0000000..d943cd9 --- /dev/null +++ b/Tests/SmartyStreetsTests/URLPrefixSenderTests.swift @@ -0,0 +1,40 @@ +import XCTest +@testable import SmartyStreets + +class URLPrefixSenderTests: XCTestCase { + + var urlPrefixSender:URLPrefixSender! + + override func setUp() { + super.setUp() + let nilInner: Any? = nil + self.urlPrefixSender = URLPrefixSender(urlPrefix: "http://mysite.com/lookup", inner: nilInner!) + } + + override func tearDown() { + super.tearDown() + self.urlPrefixSender = nil + } + + func testRequestURLPresent() { + let request:SmartyRequest = SmartyRequest() + request.urlPrefix = "/jimbo" + + var error: NSError? = NSError() + _ = self.urlPrefixSender.sendRequest(request: request, error: &error) + + XCTAssertEqual(request.urlPrefix, "http://mysite.com/lookup/jimbo") + + } + + func testRequestURLNotPresent() { + let request:SmartyRequest = SmartyRequest() + + var error: NSError? = NSError() + _ = self.urlPrefixSender.sendRequest(request: request, error: &error) + + XCTAssertEqual(request.urlPrefix, "http://mysite.com/lookup") + } + + +} \ No newline at end of file