Skip to content

Commit b479bf4

Browse files
committed
Fix \n\n accesibility strings
1 parent 202d5f4 commit b479bf4

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010

1111
### Removed
1212

13-
## [0.6.0](https://github.com/openium/SwiftiumTestingKit/compare/v0.5.0...v0.4.0)
13+
## [0.6.1](https://github.com/openium/SwiftiumTestingKit/compare/v0.6.1...v0.6.0)
14+
### Added
15+
16+
### Changed
17+
Fixed search for text containing \n\n
18+
19+
### Removed
20+
21+
## [0.6.0](https://github.com/openium/SwiftiumTestingKit/compare/v0.6.0...v0.5.0)
1422
### Added
1523
Add ability for solo to waitForAnimationsToFinish
1624

STKTestAppTests/STKSoloTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class STKSoloTests: XCTestCase {
4040

4141
func testWaitForText_shouldFindWhitespacedLabelTest() {
4242
// Given
43-
let texts = ["Some \n text", "Some \t text"]
43+
let texts = [
44+
"Some \n text",
45+
"Some \n\n text",
46+
"Some \n\n text \n and another",
47+
"Some \t text"
48+
]
4449
var foundTestTexts = [String: Bool]()
4550
sut.showViewControllerInCleanWindow(viewController)
4651

SwiftiumTestingKit.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
"@executable_path/Frameworks",
561561
"@loader_path/Frameworks",
562562
);
563-
MARKETING_VERSION = 0.6.0;
563+
MARKETING_VERSION = 0.6.1;
564564
PRODUCT_BUNDLE_IDENTIFIER = fr.openium.SwiftiumTestingKit;
565565
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
566566
SKIP_INSTALL = YES;
@@ -594,7 +594,7 @@
594594
"@executable_path/Frameworks",
595595
"@loader_path/Frameworks",
596596
);
597-
MARKETING_VERSION = 0.6.0;
597+
MARKETING_VERSION = 0.6.1;
598598
PRODUCT_BUNDLE_IDENTIFIER = fr.openium.SwiftiumTestingKit;
599599
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
600600
SKIP_INSTALL = YES;

SwiftiumTestingKit/STKSolo.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,19 @@ public class STKSolo: NSObject {
128128
}
129129

130130
public func accessibilityCleaned(text: String) -> String {
131-
return text.replacingOccurrences(of: "\n", with: " ")
131+
guard let regex = try? NSRegularExpression(pattern: "(?<!\n)\n(?!\n)", options: []) else { return text }
132+
133+
return regex.stringByReplacingMatches(
134+
in: text,
135+
options: [],
136+
range: NSMakeRange(0, text.count),
137+
withTemplate: " "
138+
)
132139
}
133140

134141
public func waitFor(text: String) -> Bool {
135142
let cleanedText = accessibilityCleaned(text: text)
143+
print("Cleaned: \(cleanedText)")
136144
let element = waitForAccessibilityElement { $0.accessibilityLabel == cleanedText }
137145
return element != nil
138146
}

0 commit comments

Comments
 (0)