mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
d7072fc66d
Rename `MasStoreSearch` as `ITunesSearchAppStoreSearcher`. Rename `StoreSearchMock` as `MockAppStoreSearcher`. Rename variables/parameters of the above types as `searcher`. Fix 'App Store.app' mention in help. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
31 lines
693 B
Swift
31 lines
693 B
Swift
//
|
|
// MockAppStoreSearcher.swift
|
|
// masTests
|
|
//
|
|
// Created by Ben Chatelain on 1/4/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
|
|
import PromiseKit
|
|
|
|
@testable import mas
|
|
|
|
class MockAppStoreSearcher: AppStoreSearcher {
|
|
var apps: [AppID: SearchResult] = [:]
|
|
|
|
func search(for searchTerm: String) -> Promise<[SearchResult]> {
|
|
.value(apps.filter { $1.trackName.contains(searchTerm) }.map { $1 })
|
|
}
|
|
|
|
func lookup(appID: AppID) -> Promise<SearchResult?> {
|
|
guard let result = apps[appID] else {
|
|
return Promise(error: MASError.noSearchResultsFound)
|
|
}
|
|
|
|
return .value(result)
|
|
}
|
|
|
|
func reset() {
|
|
apps = [:]
|
|
}
|
|
}
|