Skip to content

Commit

Permalink
Fix \n\n accesibility strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Drusy committed Apr 14, 2020
1 parent 202d5f4 commit b479bf4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Removed

## [0.6.0](https://github.com/openium/SwiftiumTestingKit/compare/v0.5.0...v0.4.0)
## [0.6.1](https://github.com/openium/SwiftiumTestingKit/compare/v0.6.1...v0.6.0)
### Added

### Changed
Fixed search for text containing \n\n

### Removed

## [0.6.0](https://github.com/openium/SwiftiumTestingKit/compare/v0.6.0...v0.5.0)
### Added
Add ability for solo to waitForAnimationsToFinish

Expand Down
7 changes: 6 additions & 1 deletion STKTestAppTests/STKSoloTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class STKSoloTests: XCTestCase {

func testWaitForText_shouldFindWhitespacedLabelTest() {
// Given
let texts = ["Some \n text", "Some \t text"]
let texts = [
"Some \n text",
"Some \n\n text",
"Some \n\n text \n and another",
"Some \t text"
]
var foundTestTexts = [String: Bool]()
sut.showViewControllerInCleanWindow(viewController)

Expand Down
4 changes: 2 additions & 2 deletions SwiftiumTestingKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.6.1;
PRODUCT_BUNDLE_IDENTIFIER = fr.openium.SwiftiumTestingKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -594,7 +594,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.6.1;
PRODUCT_BUNDLE_IDENTIFIER = fr.openium.SwiftiumTestingKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
10 changes: 9 additions & 1 deletion SwiftiumTestingKit/STKSolo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,19 @@ public class STKSolo: NSObject {
}

public func accessibilityCleaned(text: String) -> String {
return text.replacingOccurrences(of: "\n", with: " ")
guard let regex = try? NSRegularExpression(pattern: "(?<!\n)\n(?!\n)", options: []) else { return text }

return regex.stringByReplacingMatches(
in: text,
options: [],
range: NSMakeRange(0, text.count),
withTemplate: " "
)
}

public func waitFor(text: String) -> Bool {
let cleanedText = accessibilityCleaned(text: text)
print("Cleaned: \(cleanedText)")
let element = waitForAccessibilityElement { $0.accessibilityLabel == cleanedText }
return element != nil
}
Expand Down

0 comments on commit b479bf4

Please sign in to comment.