mas/Tests/masTests/Controllers/StoreSearchMock.swift
Ross Goldberg 0b11f3737c
Rename some uses of appName as searchTerm.
Partial #585

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-10-25 22:51:07 -04:00

31 lines
678 B
Swift

//
// StoreSearchMock.swift
// masTests
//
// Created by Ben Chatelain on 1/4/19.
// Copyright © 2019 mas-cli. All rights reserved.
//
import PromiseKit
@testable import mas
class StoreSearchMock: StoreSearch {
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 = [:]
}
}