2020-03-29 03:15:07 +00:00
|
|
|
//
|
2024-10-26 00:48:03 +00:00
|
|
|
// SoftwareMapAppLibrarySpec.swift
|
2024-10-01 18:05:41 +00:00
|
|
|
// masTests
|
2020-03-29 03:15:07 +00:00
|
|
|
//
|
|
|
|
// Created by Ben Chatelain on 3/1/20.
|
|
|
|
// 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-26 00:48:03 +00:00
|
|
|
public class SoftwareMapAppLibrarySpec: QuickSpec {
|
2024-10-18 14:28:44 +00:00
|
|
|
override public func spec() {
|
2024-10-26 03:09:31 +00:00
|
|
|
let library = SoftwareMapAppLibrary(softwareMap: MockSoftwareMap(products: apps))
|
2020-05-14 04:15:47 +00:00
|
|
|
|
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-03-29 03:15:07 +00:00
|
|
|
describe("mas app library") {
|
|
|
|
it("contains all installed apps") {
|
2024-10-02 02:16:06 +00:00
|
|
|
expect(library.installedApps).to(haveCount(apps.count))
|
2020-05-14 04:15:47 +00:00
|
|
|
expect(library.installedApps.first!.appName) == myApp.appName
|
|
|
|
}
|
|
|
|
it("can locate an app by bundle id") {
|
2024-10-25 16:49:21 +00:00
|
|
|
expect(library.installedApp(forBundleID: "com.example")!.bundleIdentifier) == myApp.bundleIdentifier
|
2020-03-29 03:15:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Test Data
|
2024-10-26 03:09:31 +00:00
|
|
|
let myApp = MockSoftwareProduct(
|
2020-05-14 04:15:47 +00:00
|
|
|
appName: "MyApp",
|
|
|
|
bundleIdentifier: "com.example",
|
2021-05-12 19:11:21 +00:00
|
|
|
bundlePath: "/Applications/MyApp.app",
|
|
|
|
bundleVersion: "1.0.0",
|
2021-03-22 05:46:17 +00:00
|
|
|
itemIdentifier: 1234
|
|
|
|
)
|
2020-03-29 03:15:07 +00:00
|
|
|
|
2021-03-22 05:25:18 +00:00
|
|
|
var apps: [SoftwareProduct] = [myApp]
|
2020-03-29 03:15:07 +00:00
|
|
|
|
2024-10-26 03:09:31 +00:00
|
|
|
// MARK: - MockSoftwareMap
|
|
|
|
struct MockSoftwareMap: SoftwareMap {
|
2020-03-29 03:15:07 +00:00
|
|
|
var products: [SoftwareProduct] = []
|
|
|
|
|
|
|
|
func allSoftwareProducts() -> [SoftwareProduct] {
|
2021-03-22 05:46:17 +00:00
|
|
|
products
|
2020-03-29 03:15:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func product(for bundleIdentifier: String) -> SoftwareProduct? {
|
2020-05-15 03:08:38 +00:00
|
|
|
for product in products where product.bundleIdentifier == bundleIdentifier {
|
|
|
|
return product
|
2020-03-29 03:15:07 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|