mirror of
https://github.com/mas-cli/mas
synced 2024-11-26 13:30:18 +00:00
d413d8cfa1
Move MasKitTests module to masTests. Rename MasKit enum as Mas. Upgrade swift-tools-version from 5.3 to 5.6.1. swift-tools-version 5.5+ is necessary to allow test code to import executable target code, to allow MasKit library code to be moved into the mas executable. Upgrade to swift-tools-version to 5.6.1 instead of to 5.5 because they support all the same macOS versions. Standardize comments. Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
90 lines
3 KiB
Swift
90 lines
3 KiB
Swift
//
|
|
// SearchResultFormatterSpec.swift
|
|
// masTests
|
|
//
|
|
// Created by Ben Chatelain on 1/14/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
|
|
import Nimble
|
|
import Quick
|
|
|
|
@testable import mas
|
|
|
|
public class SearchResultsFormatterSpec: QuickSpec {
|
|
override public func spec() {
|
|
// static func reference
|
|
let format = SearchResultFormatter.format(results:includePrice:)
|
|
var results: [SearchResult] = []
|
|
|
|
beforeSuite {
|
|
Mas.initialize()
|
|
}
|
|
describe("search results formatter") {
|
|
beforeEach {
|
|
results = []
|
|
}
|
|
it("formats nothing as empty string") {
|
|
let output = format(results, false)
|
|
expect(output) == ""
|
|
}
|
|
it("can format a single result") {
|
|
let result = SearchResult(
|
|
price: 9.87,
|
|
trackId: 12345,
|
|
trackName: "Awesome App",
|
|
version: "19.2.1"
|
|
)
|
|
let output = format([result], false)
|
|
expect(output) == " 12345 Awesome App (19.2.1)"
|
|
}
|
|
it("can format a single result with price") {
|
|
let result = SearchResult(
|
|
price: 9.87,
|
|
trackId: 12345,
|
|
trackName: "Awesome App",
|
|
version: "19.2.1"
|
|
)
|
|
let output = format([result], true)
|
|
expect(output) == " 12345 Awesome App $ 9.87 (19.2.1)"
|
|
}
|
|
it("can format a two results") {
|
|
results = [
|
|
SearchResult(
|
|
price: 9.87,
|
|
trackId: 12345,
|
|
trackName: "Awesome App",
|
|
version: "19.2.1"
|
|
),
|
|
SearchResult(
|
|
price: 0.01,
|
|
trackId: 67890,
|
|
trackName: "Even Better App",
|
|
version: "1.2.0"
|
|
),
|
|
]
|
|
let output = format(results, false)
|
|
expect(output) == " 12345 Awesome App (19.2.1)\n 67890 Even Better App (1.2.0)"
|
|
}
|
|
it("can format a two results with prices") {
|
|
results = [
|
|
SearchResult(
|
|
price: 9.87,
|
|
trackId: 12345,
|
|
trackName: "Awesome App",
|
|
version: "19.2.1"
|
|
),
|
|
SearchResult(
|
|
price: 0.01,
|
|
trackId: 67890,
|
|
trackName: "Even Better App",
|
|
version: "1.2.0"
|
|
),
|
|
]
|
|
let output = format(results, true)
|
|
expect(output)
|
|
== " 12345 Awesome App $ 9.87 (19.2.1)\n 67890 Even Better App $ 0.01 (1.2.0)"
|
|
}
|
|
}
|
|
}
|
|
}
|