mas/Tests/MasKitTests/Formatters/AppListFormatterSpec.swift

65 lines
2 KiB
Swift
Raw Normal View History

2020-08-23 20:06:09 +00:00
//
// AppListFormatterSpec.swift
// MasKitTests
//
// Created by Ben Chatelain on 8/23/2020.
// Copyright © 2020 mas-cli. All rights reserved.
//
import Nimble
import Quick
2021-03-22 05:25:18 +00:00
@testable import MasKit
2021-05-08 22:49:32 +00:00
public class AppListsFormatterSpec: QuickSpec {
public override 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 {
MasKit.initialize()
}
2020-08-23 20:06:09 +00:00
describe("app list formatter") {
beforeEach {
products = []
}
it("formats nothing as empty string") {
let output = format(products)
expect(output) == ""
}
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
)
let output = format([product])
2020-08-23 20:06:09 +00:00
expect(output) == "12345 Awesome App (19.2.1)"
}
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
]
let output = format(products)
2021-03-22 05:25:18 +00:00
expect(output) == "12345 Awesome App (19.2.1)\n67890 Even Better App (1.2.0)"
2020-08-23 20:06:09 +00:00
}
}
}
}