Brion VIBBER has submitted this change and it was merged.
Change subject: add prefixedText read property on PageTitle
......................................................................
add prefixedText read property on PageTitle
Change-Id: I67dded66470eddf0e017525f38e26f9bd7be7ec5
---
M Wikipedia-iOS/mw-support/PageTitle.h
M Wikipedia-iOS/mw-support/PageTitle.m
M Wikipedia-iOSTests/Wikipedia_iOSTests.m
M Wikipedia-iOSTests/mw-support/PageTitleTests.m
4 files changed, 35 insertions(+), 5 deletions(-)
Approvals:
Brion VIBBER: Verified; Looks good to me, approved
diff --git a/Wikipedia-iOS/mw-support/PageTitle.h
b/Wikipedia-iOS/mw-support/PageTitle.h
index bb07252..e2290cb 100644
--- a/Wikipedia-iOS/mw-support/PageTitle.h
+++ b/Wikipedia-iOS/mw-support/PageTitle.h
@@ -16,5 +16,6 @@
-(NSString *)namespace;
-(NSString *)text;
+-(NSString *)prefixedText;
@end
diff --git a/Wikipedia-iOS/mw-support/PageTitle.m
b/Wikipedia-iOS/mw-support/PageTitle.m
index 987ba0b..a398be1 100644
--- a/Wikipedia-iOS/mw-support/PageTitle.m
+++ b/Wikipedia-iOS/mw-support/PageTitle.m
@@ -38,4 +38,17 @@
return _text;
}
+-(NSString *)prefix
+{
+ if (self.namespace.length == 0) {
+ return @"";
+ } else {
+ return [self.namespace stringByAppendingString:@":"];
+ }
+}
+-(NSString *)prefixedText
+{
+ return [self.prefix stringByAppendingString:self.text];
+}
+
@end
diff --git a/Wikipedia-iOSTests/Wikipedia_iOSTests.m
b/Wikipedia-iOSTests/Wikipedia_iOSTests.m
index 3ba8c5d..3117832 100644
--- a/Wikipedia-iOSTests/Wikipedia_iOSTests.m
+++ b/Wikipedia-iOSTests/Wikipedia_iOSTests.m
@@ -23,6 +23,7 @@
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of
each test method in the class.
+ NSLog(@"done"); // crazy hack for "tests not finished"
[super tearDown];
}
diff --git a/Wikipedia-iOSTests/mw-support/PageTitleTests.m
b/Wikipedia-iOSTests/mw-support/PageTitleTests.m
index 8ecddc2..8be7ea3 100644
--- a/Wikipedia-iOSTests/mw-support/PageTitleTests.m
+++ b/Wikipedia-iOSTests/mw-support/PageTitleTests.m
@@ -25,16 +25,31 @@
- (void)tearDown
{
// Put teardown code here; it will be run once, after the last test case.
+
+ // crazy hack for "tests not finished"
+ [NSThread sleepForTimeInterval:1.0];
+ NSLog(@"done");
+
[super tearDown];
}
- (void)testCreate
{
- NSString *ns = @"";
- NSString *text = @"Test-driven developent";
- PageTitle *title = [PageTitle titleFromNamespace:ns text:text];
- XCTAssert([title.namespace isEqualToString:ns], @"Title namespace should
be what we passed in");
- XCTAssert([title.text isEqualToString:text], @"Title text should be what
we passed in");
+ NSArray *dataSet = @[@{@"prefixed": @"Test-driven development",
+ @"ns": @"",
+ @"text": @"Test-driven development"},
+ @{@"prefixed": @"Talk:Test-driven development",
+ @"ns": @"Talk",
+ @"text": @"Test-driven development"}];
+ for (NSDictionary *data in dataSet) {
+ NSString *ns = data[@"ns"];;
+ NSString *text = data[@"text"];
+
+ PageTitle *title = [PageTitle titleFromNamespace:ns text:text];
+ XCTAssertEqualObjects(title.namespace, ns, @"Title namespace check");
+ XCTAssertEqualObjects(title.text, text, @"Title text check");
+ XCTAssertEqualObjects(title.prefixedText, data[@"prefixed"],
@"Prefixed text check");
+ }
}
@end
--
To view, visit https://gerrit.wikimedia.org/r/93111
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I67dded66470eddf0e017525f38e26f9bd7be7ec5
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits