mas/Tests/masTests/Formatters/AppListFormatterSpec.swift

63 lines
1.9 KiB
Swift
Raw Normal View History

2020-08-23 20:06:09 +00:00
//
// AppListFormatterSpec.swift
// masTests
2020-08-23 20:06:09 +00:00
//
// Created by Ben Chatelain on 8/23/2020.
// Copyright © 2020 mas-cli. All rights reserved.
//
import Nimble
import Quick
@testable import mas
2021-03-22 05:25:18 +00:00
public class AppListFormatterSpec: QuickSpec {
override public func spec() {
2020-08-23 20:06:09 +00:00
// static func reference
let format = AppListFormatter.format(products:)
var products: [SoftwareProduct] = []
2021-04-23 07:01:18 +00:00
beforeSuite {
MAS.initialize()
2021-04-23 07:01:18 +00:00
}
2020-08-23 20:06:09 +00:00
describe("app list formatter") {
beforeEach {
products = []
}
it("formats nothing as empty string") {
expect(format(products)).to(beEmpty())
2020-08-23 20:06:09 +00:00
}
it("can format a single product") {
2021-03-22 05:25:18 +00:00
let product = SoftwareProductMock(
2020-08-23 20:06:09 +00:00
appName: "Awesome App",
bundleIdentifier: "",
bundlePath: "",
bundleVersion: "19.2.1",
itemIdentifier: 12345
2021-03-22 05:25:18 +00:00
)
expect(format([product])) == "12345 Awesome App (19.2.1)"
2020-08-23 20:06:09 +00:00
}
it("can format two products") {
products = [
SoftwareProductMock(
appName: "Awesome App",
bundleIdentifier: "",
bundlePath: "",
bundleVersion: "19.2.1",
itemIdentifier: 12345
),
SoftwareProductMock(
appName: "Even Better App",
bundleIdentifier: "",
bundlePath: "",
bundleVersion: "1.2.0",
itemIdentifier: 67890
2021-03-22 05:25:18 +00:00
),
2020-08-23 20:06:09 +00:00
]
expect(format(products))
== "12345 Awesome App (19.2.1)\n67890 Even Better App (1.2.0)"
2020-08-23 20:06:09 +00:00
}
}
}
}