2018-12-28 22:23:22 +00:00
|
|
|
//
|
|
|
|
// SearchCommandSpec.swift
|
|
|
|
// MasKitTests
|
|
|
|
//
|
|
|
|
// Created by Ben Chatelain on 2018-12-28.
|
|
|
|
// Copyright © 2018 mas-cli. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Nimble
|
2019-01-30 06:15:24 +00:00
|
|
|
import Quick
|
2018-12-28 22:23:22 +00:00
|
|
|
|
2021-03-22 05:25:18 +00:00
|
|
|
@testable import MasKit
|
|
|
|
|
2018-12-28 22:23:22 +00:00
|
|
|
class SearchCommandSpec: QuickSpec {
|
|
|
|
override func spec() {
|
2019-01-12 02:46:23 +00:00
|
|
|
let result = SearchResult(
|
|
|
|
trackId: 1111,
|
|
|
|
trackName: "slack",
|
|
|
|
trackViewUrl: "mas preview url",
|
|
|
|
version: "0.0"
|
|
|
|
)
|
|
|
|
let storeSearch = StoreSearchMock()
|
|
|
|
|
2018-12-28 22:23:22 +00:00
|
|
|
describe("search command") {
|
2019-01-12 02:46:23 +00:00
|
|
|
beforeEach {
|
|
|
|
storeSearch.reset()
|
2019-01-12 02:35:55 +00:00
|
|
|
}
|
2019-01-12 02:46:23 +00:00
|
|
|
it("can find slack") {
|
|
|
|
storeSearch.apps[result.trackId] = result
|
2019-01-12 02:35:55 +00:00
|
|
|
|
2019-01-12 02:46:23 +00:00
|
|
|
let search = SearchCommand(storeSearch: storeSearch)
|
|
|
|
let searchOptions = SearchOptions(appName: "slack", price: false)
|
|
|
|
let result = search.run(searchOptions)
|
|
|
|
expect(result).to(beSuccess())
|
|
|
|
}
|
|
|
|
it("fails when searching for nonexistent app") {
|
|
|
|
let search = SearchCommand(storeSearch: storeSearch)
|
|
|
|
let searchOptions = SearchOptions(appName: "nonexistent", price: false)
|
|
|
|
let result = search.run(searchOptions)
|
2021-03-22 05:25:18 +00:00
|
|
|
expect(result)
|
|
|
|
.to(
|
|
|
|
beFailure { error in
|
|
|
|
expect(error) == .noSearchResultsFound
|
|
|
|
})
|
2018-12-28 22:23:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|