Ensure Plain BPMF tests run with Standard layout

This exposes an issue that our Preferences is a global singleton that
uses the user defaults store and is therefore not hermetic.
This commit is contained in:
Lukhnos Liu 2022-02-15 23:27:22 -08:00
parent fda39761ec
commit 5d53b4a93c
1 changed files with 7 additions and 0 deletions

View File

@ -25,15 +25,22 @@ import XCTest
@testable import McBopomofo
class KeyHandlerPlainBopomofoTests: XCTestCase {
var savedKeyboardLayout: Int = 0
var handler = KeyHandler()
override func setUpWithError() throws {
LanguageModelManager.loadDataModels()
handler = KeyHandler()
handler.inputMode = .plainBopomofo
savedKeyboardLayout = Preferences.keyboardLayout
// Punctuation-related tests only work when the layout is Standard.
Preferences.keyboardLayout = KeyboardLayout.standard.rawValue
}
override func tearDownWithError() throws {
Preferences.keyboardLayout = savedKeyboardLayout
}
func testPunctuationTable() {