Skip to content

Commit

Permalink
Fix Quick/Nimble warnings in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Dec 28, 2020
1 parent 33c5b30 commit 3c96a25
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
26 changes: 22 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
{
"object": {
"pins": [
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "f809deb30dc5c9d9b78c872e553261a61177721a",
"version": "2.0.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f",
"version": "2.0.0"
}
},
{
"package": "Mockery",
"repositoryURL": "https://github.com/danielsaidi/Mockery.git",
"state": {
"branch": null,
"revision": "c72143b88863ca4852993a448aadbe9def3f8b30",
"version": "0.6.1"
"revision": "bee41ba4c96d2d4f31129744a1dadbbf2f50a0f1",
"version": "0.7.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
"state": {
"branch": null,
"revision": "2b1809051b4a65c1d7f5233331daa24572cd7fca",
"version": "8.1.1"
"revision": "e491a6731307bb23783bf664d003be9b2fa59ab5",
"version": "9.0.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "3.0.0")),
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.1.1")),
.package(url: "https://github.com/danielsaidi/Mockery.git", .upToNextMajor(from: "0.6.1"))
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "9.0.0")),
.package(url: "https://github.com/danielsaidi/Mockery.git", .upToNextMajor(from: "0.7.0"))
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ open class StandardKeyboardActionHandler: NSObject, KeyboardActionHandler {
private extension StandardKeyboardActionHandler {

func shouldChangeToAlphabeticLowercase(after gesture: KeyboardGesture, on action: KeyboardAction) -> Bool {
guard let type = inputViewController?.context.keyboardType else { return false }
guard case .alphabetic(.uppercased) = type else { return false }
guard let keyboardType = inputViewController?.context.keyboardType else { return false }
guard case .alphabetic(.uppercased) = keyboardType else { return false }
guard case .tap = gesture else { return false }
guard case .character = action else { return false }
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class StandardKeyboardActionHandlerTests: QuickSpec {
}

it("is defined for character tap in uppercased alphabetic keyboard") {
expect(result(for: .tap, on: .character("foo"), current: .alphabetic(.uppercased))).to(equal(.alphabetic(.lowercased)))
expect(result(for: .tap, on: .character("foo"), current: .alphabetic(.uppercased))).to(equal(KeyboardType.alphabetic(.lowercased)))
expect(result(for: .tap, on: .character("foo"), current: .alphabetic(.capsLocked))).to(beNil())
expect(result(for: .tap, on: .character("foo"), current: .alphabetic(.lowercased))).to(beNil())
expect(result(for: .tap, on: .image(description: "", keyboardImageName: "", imageName: ""), current: .numeric)).to(beNil())
Expand Down
6 changes: 3 additions & 3 deletions Tests/KeyboardKitTests/Keyboard/KeyboardTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class KeyboardTypeTests: QuickSpec {
}

it("is only defined for some types") {
expect(result(for: .alphabetic(.lowercased))).to(equal(.shift(currentState: .lowercased)))
expect(result(for: .alphabetic(.uppercased))).to(equal(.shift(currentState: .uppercased)))
expect(result(for: .alphabetic(.capsLocked))).to(equal(.shift(currentState: .uppercased)))
expect(result(for: .alphabetic(.lowercased))).to(equal(KeyboardAction.shift(currentState: .lowercased)))
expect(result(for: .alphabetic(.uppercased))).to(equal(KeyboardAction.shift(currentState: .uppercased)))
expect(result(for: .alphabetic(.capsLocked))).to(equal(KeyboardAction.shift(currentState: .uppercased)))
expect(result(for: .numeric)).to(equal(.keyboardType(.symbolic)))
expect(result(for: .symbolic)).to(equal(.keyboardType(.numeric)))
expect(result(for: .email)).to(beNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class StandardKeyboardLayoutProviderTests: QuickSpec {
let lowerFirst = lower.first
let lowerLast = lower.last
let lowerCenter = lower.filter { $0 != lowerFirst && $0 != lowerLast }
expect(lowerFirst).to(equal(.shift(currentState: .lowercased)))
expect(lowerFirst).to(equal(KeyboardAction.shift(currentState: .lowercased)))
expect(lowerCenter).to(equal(rows[2]))
expect(lowerLast).to(equal(.backspace))
}
Expand All @@ -60,12 +60,12 @@ class StandardKeyboardLayoutProviderTests: QuickSpec {
it("is correct for a home button pad") {
context.needsInputModeSwitchKey = true
let result = provider.keyboardLayout(for: context, iPad: true, rows: rows).actionRows
expect(result[0].first).to(equal(.character("q")))
expect(result[0].first).to(equal(KeyboardAction.character("q")))
expect(result[0].last).to(equal(.backspace))
expect(result[1].first).to(equal(.character("a")))
expect(result[1].first).to(equal(KeyboardAction.character("a")))
expect(result[1].last).to(equal(.newLine))
expect(result[2].first).to(equal(.shift(currentState: .lowercased)))
expect(result[2].last).to(equal(.shift(currentState: .lowercased)))
expect(result[2].first).to(equal(KeyboardAction.shift(currentState: .lowercased)))
expect(result[2].last).to(equal(KeyboardAction.shift(currentState: .lowercased)))
let bottom: [KeyboardAction] = [.keyboardType(.numeric), .nextKeyboard, .done, .space, .escape, .keyboardType(.numeric), .dismissKeyboard]
expect(result[3]).to(equal(bottom))
}
Expand All @@ -77,8 +77,8 @@ class StandardKeyboardLayoutProviderTests: QuickSpec {
expect(result[0].last).to(equal(.backspace))
expect(result[1].first).to(equal(.keyboardType(.alphabetic(.capsLocked))))
expect(result[1].last).to(equal(.newLine))
expect(result[2].first).to(equal(.shift(currentState: .lowercased)))
expect(result[2].last).to(equal(.shift(currentState: .lowercased)))
expect(result[2].first).to(equal(KeyboardAction.shift(currentState: .lowercased)))
expect(result[2].last).to(equal(KeyboardAction.shift(currentState: .lowercased)))
let bottom: [KeyboardAction] = [.nextKeyboard, .keyboardType(.numeric), .done, .space, .escape, .keyboardType(.numeric), .dismissKeyboard]
expect(result[3]).to(equal(bottom))
}
Expand Down

0 comments on commit 3c96a25

Please sign in to comment.