mas/MasKitTests/Controllers/MasStoreSearchSpec.swift

64 lines
2.3 KiB
Swift
Raw Normal View History

2019-01-05 15:39:07 +00:00
//
// MasStoreSearchSpec.swift
// MasKitTests
//
// Created by Ben Chatelain on 1/4/19.
// Copyright © 2019 mas-cli. All rights reserved.
//
@testable import MasKit
import Result
import Quick
import Nimble
class MasStoreSearchSpec: QuickSpec {
override func spec() {
describe("store search") {
2019-01-12 00:33:41 +00:00
it("can find slack") {
let networkSession = NetworkSessionMockFromFile(responseFile: "search/slack.json")
let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession))
2019-01-12 00:11:53 +00:00
var searchList: SearchResultList
do {
searchList = try storeSearch.search(for: "slack")
expect(searchList.resultCount) == 6
expect(searchList.results.count) == 6
} catch {
let maserror = error as! MASError
if case .jsonParsing(let nserror) = maserror {
fail("\(maserror) \(nserror!)")
}
}
}
}
describe("store lookup") {
2019-01-05 15:39:07 +00:00
it("can find slack") {
let appId = 803453959
let networkSession = NetworkSessionMockFromFile(responseFile: "lookup/slack.json")
let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession))
2019-01-12 00:33:41 +00:00
var lookup: SearchResult?
do {
lookup = try storeSearch.lookup(app: appId)
2019-01-12 00:33:41 +00:00
} catch {
let maserror = error as! MASError
if case .jsonParsing(let nserror) = maserror {
fail("\(maserror) \(nserror!)")
}
}
guard let result = lookup else { fatalError("lookup result was nil") }
2019-01-05 15:39:07 +00:00
expect(result.trackId) == appId
expect(result.bundleId) == "com.tinyspeck.slackmacgap"
expect(result.price) == 0
expect(result.sellerName) == "Slack Technologies, Inc."
expect(result.sellerUrl) == "https://slack.com"
expect(result.trackName) == "Slack"
expect(result.trackViewUrl) == "https://itunes.apple.com/us/app/slack/id803453959?mt=12&uo=4"
expect(result.version) == "3.3.3"
2019-01-05 15:39:07 +00:00
}
}
}
}