mas/Tests/masTests/Commands/VendorSpec.swift
Ross Goldberg 2535e3da42
Use Swift Argument Parser instead of Commandant.
Command structs are nested types of Mas.

Renamed structs.

Limit code visibility as much as possible.

Standardize variable names.

Standardize spacing.

Fix a few tests.

Disable a useless test.

Remove unnecessary test stdout output.

Get swift-format from Brewfile instead of from Package.swift
since swift-format depends on an old version of swift-argument-parser.

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

63 lines
1.9 KiB
Swift

//
// VendorSpec.swift
// masTests
//
// Created by Ben Chatelain on 2019-01-03.
// Copyright © 2019 mas-cli. All rights reserved.
//
import Nimble
import Quick
@testable import mas
public class VendorSpec: QuickSpec {
override public func spec() {
let result = SearchResult(
trackId: 1111,
trackViewUrl: "https://awesome.app",
version: "0.0"
)
let storeSearch = StoreSearchMock()
let openCommand = OpenSystemCommandMock()
beforeSuite {
Mas.initialize()
}
describe("vendor command") {
beforeEach {
storeSearch.reset()
}
it("fails to open app with invalid ID") {
expect {
try Mas.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(
beFailure { error in
expect(error) == .searchFailed
}
)
}
it("can't find app with unknown ID") {
expect {
try Mas.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(
beFailure { error in
expect(error) == .noSearchResultsFound
}
)
}
it("opens vendor app page in browser") {
storeSearch.apps[result.trackId] = result
expect {
try Mas.Vendor.parse([String(result.trackId)])
.run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(beSuccess())
expect(openCommand.arguments).toNot(beNil())
expect(openCommand.arguments!.first!) == result.sellerUrl
}
}
}
}