mas/Tests/masTests/Commands/OpenSpec.swift
Ross Goldberg c0fffeddf3
Open the Mac App Store without any spurious error dialogs.
Use PromiseKit properly.

Don't use `OpenCommand`.

Resolve #217

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-10-28 10:17:33 -04:00

56 lines
1.6 KiB
Swift

//
// OpenSpec.swift
// masTests
//
// Created by Ben Chatelain on 2019-01-03.
// Copyright © 2019 mas-cli. All rights reserved.
//
import Foundation
import Nimble
import Quick
@testable import mas
public class OpenSpec: QuickSpec {
override public func spec() {
let searcher = MockAppStoreSearcher()
beforeSuite {
MAS.initialize()
}
describe("open command") {
beforeEach {
searcher.reset()
}
it("fails to open app with invalid ID") {
expect {
try MAS.Open.parse(["--", "-999"]).run(searcher: searcher)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try MAS.Open.parse(["999"]).run(searcher: searcher)
}
.to(throwError(MASError.noSearchResultsFound))
}
xit("opens app in MAS") {
let mockResult = SearchResult(
trackId: 1111,
trackViewUrl: "fakescheme://some/url",
version: "0.0"
)
searcher.apps[mockResult.trackId] = mockResult
expect {
try MAS.Open.parse([mockResult.trackId.description]).run(searcher: searcher)
}
}
xit("just opens MAS if no app specified") {
expect {
try MAS.Open.parse([]).run(searcher: searcher)
}
}
}
}
}