mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add first Web test. Add WebTests to test plans.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Dictionary+RSWeb.swift
|
||||
// Dictionary+Web.swift
|
||||
// RSWeb
|
||||
//
|
||||
// Created by Brent Simmons on 1/13/18.
|
||||
@@ -13,12 +13,13 @@ public extension Dictionary where Key == String, Value == String {
|
||||
/// Translates a dictionary into a string like `foo=bar¶m2=some%20thing`.
|
||||
var urlQueryString: String? {
|
||||
|
||||
var components = URLComponents()
|
||||
|
||||
components.queryItems = self.reduce(into: [URLQueryItem]()) {
|
||||
$0.append(URLQueryItem(name: $1.key, value: $1.value))
|
||||
var queryItems = [URLQueryItem]()
|
||||
for (key, value) in self {
|
||||
queryItems.append(URLQueryItem(name: key, value: value))
|
||||
}
|
||||
|
||||
var components = URLComponents()
|
||||
components.queryItems = queryItems
|
||||
let s = components.percentEncodedQuery
|
||||
|
||||
return s == nil || s!.isEmpty ? nil : s
|
||||
20
Web/Tests/WebTests/DictionaryWebTests.swift
Normal file
20
Web/Tests/WebTests/DictionaryWebTests.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// DictionaryWebTests.swift
|
||||
//
|
||||
//
|
||||
// Created by Brent Simmons on 5/20/24.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Web
|
||||
|
||||
final class DictionaryWebTests: XCTestCase {
|
||||
|
||||
func testURLQueryString_oneItemNoEscaping() {
|
||||
|
||||
let d = ["parameterName" : "value"]
|
||||
let queryString = d.urlQueryString
|
||||
let expectedQueryString = "parameterName=value"
|
||||
XCTAssertEqual(queryString, expectedQueryString)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import XCTest
|
||||
@testable import Web
|
||||
|
||||
final class WebTests: XCTestCase {
|
||||
func testExample() throws {
|
||||
// XCTest Documentation
|
||||
// https://developer.apple.com/documentation/xctest
|
||||
|
||||
// Defining Test Cases and Test Methods
|
||||
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user