From ed0fbb038c1d24aad1edd6d13681ff4e02488dca Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 13 Jul 2020 09:56:51 +0700 Subject: [PATCH] feat(ios/engine): package-local install state unit test --- .../KeymanPackageTests.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ios/engine/KMEI/KeymanEngineTests/KeymanPackageTests.swift b/ios/engine/KMEI/KeymanEngineTests/KeymanPackageTests.swift index 425fdc6705..bcca979193 100644 --- a/ios/engine/KMEI/KeymanEngineTests/KeymanPackageTests.swift +++ b/ios/engine/KMEI/KeymanEngineTests/KeymanPackageTests.swift @@ -323,4 +323,25 @@ class KeymanPackageTests: XCTestCase { wait(for: [expectationUpdate], timeout: 5) XCTAssertEqual(package.versionState, .needsUpdate) } + + func testInstallState() throws { + // Step 1: Install khmer_angkor. Fixture: version 1.0.6. + guard let installPackage = try ResourceFileManager.shared.prepareKMPInstall(from: TestUtils.Keyboards.khmerAngkorKMP) as? KeyboardKeymanPackage else { + XCTFail("Could not load keyboard KMP for test") + return + } + + XCTAssertEqual(installPackage.installState, .pending) + + try ResourceFileManager.shared.install(resourceWithID: TestUtils.Keyboards.khmer_angkor.fullID, from: installPackage) + + // Step 2: retrieve an instance for the installation. We're currently using the temp version. + guard let package = ResourceFileManager.shared.getInstalledPackage(withKey: installPackage.key) else { + XCTFail("Could not load installed form of keyboard KMP for test") + return + } + + XCTAssertEqual(installPackage.installState, .pending) // Reflects that the instance is a temporary extraction. + XCTAssertEqual(package.installState, .installed) // Reflects the actually-installed package + } }