mas/Tests/masTests/Commands/HomeSpec.swift
Ross Goldberg 7cd8c1436b
Downgrade Nimble & Quick to fix testing on newer Xcode versions.
Resolve #583

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

54 lines
1.6 KiB
Swift

//
// HomeSpec.swift
// masTests
//
// Created by Ben Chatelain on 2018-12-29.
// Copyright © 2018 mas-cli. All rights reserved.
//
import Nimble
import Quick
@testable import mas
public class HomeSpec: QuickSpec {
override public func spec() {
let storeSearch = StoreSearchMock()
let openCommand = OpenSystemCommandMock()
beforeSuite {
Mas.initialize()
}
describe("home command") {
beforeEach {
storeSearch.reset()
}
it("fails to open app with invalid ID") {
expect {
try Mas.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try Mas.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError(MASError.noSearchResultsFound))
}
it("opens app on MAS Preview") {
let mockResult = SearchResult(
trackId: 1111,
trackViewUrl: "mas preview url",
version: "0.0"
)
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try Mas.Home.parse([String(mockResult.trackId)])
.run(storeSearch: storeSearch, openCommand: openCommand)
return openCommand.arguments
}
== [mockResult.trackViewUrl]
}
}
}
}