mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 11:33:13 +00:00
49 lines
1.7 KiB
Swift
49 lines
1.7 KiB
Swift
//
|
|
// StoreSearchSpec.swift
|
|
// MasKitTests
|
|
//
|
|
// Created by Ben Chatelain on 1/11/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
import Nimble
|
|
import Quick
|
|
|
|
@testable import MasKit
|
|
|
|
/// Protocol minimal implementation
|
|
struct StoreSearchForTesting: StoreSearch {
|
|
func lookup(app _: Int, _ completion: @escaping (SearchResult?, Error?) -> Void) {
|
|
completion(nil, nil)
|
|
}
|
|
|
|
func search(for _: String, _ completion: @escaping ([SearchResult]?, Error?) -> Void) {
|
|
completion([], nil)
|
|
}
|
|
}
|
|
|
|
class StoreSearchSpec: QuickSpec {
|
|
override func spec() {
|
|
let storeSearch = StoreSearchForTesting()
|
|
|
|
describe("url string") {
|
|
it("contains the app name") {
|
|
let appName = "myapp"
|
|
let urlString = storeSearch.searchURLString(forApp: appName)
|
|
expect(urlString) == "https://itunes.apple.com/search?media=software&entity=macSoftware&term=\(appName)"
|
|
}
|
|
it("contains the encoded app name") {
|
|
let appName = "My App"
|
|
let appNameEncoded = "My%20App"
|
|
let urlString = storeSearch.searchURLString(forApp: appName)
|
|
expect(urlString)
|
|
== "https://itunes.apple.com/search?media=software&entity=macSoftware&term=\(appNameEncoded)"
|
|
}
|
|
// Find a character that causes addingPercentEncoding(withAllowedCharacters to return nil
|
|
xit("is nil when app name cannot be url encoded") {
|
|
let appName = "`~!@#$%^&*()_+ 💩"
|
|
let urlString = storeSearch.searchURLString(forApp: appName)
|
|
expect(urlString).to(beNil())
|
|
}
|
|
}
|
|
}
|
|
}
|