2020-08-23 20:06:09 +00:00
|
|
|
//
|
|
|
|
// AppListFormatterSpec.swift
|
2024-10-01 18:05:41 +00:00
|
|
|
// 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
|
|
|
|
|
2024-10-01 18:05:41 +00:00
|
|
|
@testable import mas
|
2021-03-22 05:25:18 +00:00
|
|
|
|
2024-10-21 11:38:51 +00:00
|
|
|
public class AppListFormatterSpec: QuickSpec {
|
2024-10-18 14:28:44 +00:00
|
|
|
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 {
|
2024-10-25 17:21:19 +00:00
|
|
|
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") {
|
2024-10-21 11:35:16 +00:00
|
|
|
expect(format(products)).to(beEmpty())
|
2020-08-23 20:06:09 +00:00
|
|
|
}
|
|
|
|
it("can format a single product") {
|
2024-10-26 03:09:31 +00:00
|
|
|
let product = MockSoftwareProduct(
|
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
|
|
|
)
|
2024-10-02 02:16:06 +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 = [
|
2024-10-26 03:09:31 +00:00
|
|
|
MockSoftwareProduct(
|
2020-08-23 20:06:09 +00:00
|
|
|
appName: "Awesome App",
|
|
|
|
bundleIdentifier: "",
|
|
|
|
bundlePath: "",
|
|
|
|
bundleVersion: "19.2.1",
|
|
|
|
itemIdentifier: 12345
|
|
|
|
),
|
2024-10-26 03:09:31 +00:00
|
|
|
MockSoftwareProduct(
|
2020-08-23 20:06:09 +00:00
|
|
|
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
|
|
|
]
|
2024-10-02 02:16:06 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|