Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 098405e

Browse files
authored
Merge pull request #522 from wordpress-mobile/issue/521-siteinfo
WordPressComSiteInfo: add properties and update parser
2 parents f4f47e2 + 5a54d12 commit 098405e

File tree

4 files changed

+81
-8
lines changed

4 files changed

+81
-8
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.29.0"
3+
s.version = "1.30.0-beta.1"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
CEDE0D93242011E000CB3345 /* NSObject+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D92242011E000CB3345 /* NSObject+Helpers.swift */; };
155155
CEDE0D952420121D00CB3345 /* UIStoryboard+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D942420121D00CB3345 /* UIStoryboard+Helpers.swift */; };
156156
CEDE0D972420126900CB3345 /* UIViewController+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D962420126900CB3345 /* UIViewController+Helpers.swift */; };
157+
D85C3882256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */; };
157158
E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; };
158159
F12F9FB424D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */; };
159160
F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */; };
@@ -353,6 +354,7 @@
353354
CEDE0D92242011E000CB3345 /* NSObject+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+Helpers.swift"; sourceTree = "<group>"; };
354355
CEDE0D942420121D00CB3345 /* UIStoryboard+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+Helpers.swift"; sourceTree = "<group>"; };
355356
CEDE0D962420126900CB3345 /* UIViewController+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Helpers.swift"; sourceTree = "<group>"; };
357+
D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressComSiteInfoTests.swift; sourceTree = "<group>"; };
356358
E9414A95E29F3297555AC92B /* Pods-WordPressAuthenticator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.debug.xcconfig"; sourceTree = "<group>"; };
357359
F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticatorAnalyticsTracker.swift; sourceTree = "<group>"; };
358360
F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsTrackerTests.swift; sourceTree = "<group>"; };
@@ -495,6 +497,7 @@
495497
isa = PBXGroup;
496498
children = (
497499
B501C03C208FC52400D1E58F /* LoginFieldsValidationTests.swift */,
500+
D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */,
498501
);
499502
path = Model;
500503
sourceTree = "<group>";
@@ -1286,6 +1289,7 @@
12861289
BA53D64B24DFE07D001F1ABF /* WordpressAuthenticatorProvider.swift in Sources */,
12871290
CE16177821B70C1A00B82A47 /* WordPressAuthenticatorDisplayTextTests.swift in Sources */,
12881291
B501C048208FC79C00D1E58F /* LoginFacadeTests.m in Sources */,
1292+
D85C3882256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift in Sources */,
12891293
F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */,
12901294
B501C046208FC6A700D1E58F /* WordPressAuthenticatorTests.swift in Sources */,
12911295
);

WordPressAuthenticator/Model/WordPressComSiteInfo.swift

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public class WordPressComSiteInfo {
2121
///
2222
public let hasJetpack: Bool
2323

24+
/// Indicates if Jetpack is active, or not.
25+
///
26+
public let isJetpackActive: Bool
27+
28+
/// Indicates if Jetpack is connected, or not.
29+
///
30+
public let isJetpackConnected: Bool
31+
2432
/// URL of the Site's Blavatar.
2533
///
2634
public let icon: String
@@ -29,17 +37,28 @@ public class WordPressComSiteInfo {
2937
///
3038
public let isWPCom: Bool
3139

40+
/// Inidcates wheter the site is WordPress, or not.
41+
///
42+
public let isWP: Bool
43+
44+
/// Inidcates whether the site exists, or not.
45+
///
46+
public let exists: Bool
47+
3248

3349

3450
/// Initializes the current SiteInfo instance with a raw dictionary.
3551
///
3652
public init(remote: [AnyHashable: Any]) {
37-
name = remote["name"] as? String ?? ""
38-
tagline = remote["description"] as? String ?? ""
39-
url = remote["URL"] as? String ?? ""
40-
hasJetpack = remote["hasJetpack"] as? Bool ?? false
41-
icon = remote["icon.img"] as? String ?? ""
42-
isWPCom = remote["isWordPressDotCom"] as? Bool ?? false
43-
53+
name = remote["name"] as? String ?? ""
54+
tagline = remote["description"] as? String ?? ""
55+
url = remote["urlAfterRedirects"] as? String ?? ""
56+
hasJetpack = remote["hasJetpack"] as? Bool ?? false
57+
isJetpackActive = remote["isJetpackActive"] as? Bool ?? false
58+
isJetpackConnected = remote["isJetpackConnected"] as? Bool ?? false
59+
icon = remote["icon.img"] as? String ?? ""
60+
isWPCom = remote["isWordPressDotCom"] as? Bool ?? false
61+
isWP = remote["isWordPress"] as? Bool ?? false
62+
exists = remote["exists"] as? Bool ?? false
4463
}
4564
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import XCTest
2+
@testable import WordPressAuthenticator
3+
4+
final class WordPressComSiteInfoTests: XCTestCase {
5+
private var subject: WordPressComSiteInfo!
6+
7+
override func setUp() {
8+
subject = WordPressComSiteInfo(remote: mock())
9+
super.setUp()
10+
}
11+
12+
override func tearDown() {
13+
super.tearDown()
14+
subject = nil
15+
}
16+
17+
func testJetpackActiveMatchesExpectation() {
18+
XCTAssertTrue(subject.isJetpackActive)
19+
}
20+
21+
func testHasJetpackMatchesExpectation() {
22+
XCTAssertTrue(subject.hasJetpack)
23+
}
24+
25+
func testJetpackConnectedMatchesExpectation() {
26+
XCTAssertTrue(subject.isJetpackConnected)
27+
}
28+
29+
func testWPComMatchesExpectation() {
30+
XCTAssertFalse(subject.isWPCom)
31+
}
32+
33+
func testWPMatchesExpectation() {
34+
XCTAssertTrue(subject.isWP)
35+
}
36+
}
37+
38+
private extension WordPressComSiteInfoTests {
39+
func mock() -> [AnyHashable: Any] {
40+
return [
41+
"isJetpackActive": true,
42+
"jetpackVersion": false,
43+
"isWordPressDotCom": false,
44+
"urlAfterRedirects": "https://somewhere.com",
45+
"hasJetpack": true,
46+
"isWordPress": true,
47+
"isJetpackConnected": true
48+
] as [AnyHashable: Any]
49+
}
50+
}

0 commit comments

Comments
 (0)