diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index bc15fa1b1..2dd19b235 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressAuthenticator" - s.version = "1.29.0" + s.version = "1.30.0-beta.1" s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps." s.description = <<-DESC diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index b1b29af52..a3f18e3a9 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -154,6 +154,7 @@ CEDE0D93242011E000CB3345 /* NSObject+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D92242011E000CB3345 /* NSObject+Helpers.swift */; }; CEDE0D952420121D00CB3345 /* UIStoryboard+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D942420121D00CB3345 /* UIStoryboard+Helpers.swift */; }; CEDE0D972420126900CB3345 /* UIViewController+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDE0D962420126900CB3345 /* UIViewController+Helpers.swift */; }; + D85C3882256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */; }; E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; }; F12F9FB424D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */; }; F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */; }; @@ -353,6 +354,7 @@ CEDE0D92242011E000CB3345 /* NSObject+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+Helpers.swift"; sourceTree = ""; }; CEDE0D942420121D00CB3345 /* UIStoryboard+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+Helpers.swift"; sourceTree = ""; }; CEDE0D962420126900CB3345 /* UIViewController+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Helpers.swift"; sourceTree = ""; }; + D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressComSiteInfoTests.swift; sourceTree = ""; }; 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 = ""; }; F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticatorAnalyticsTracker.swift; sourceTree = ""; }; F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsTrackerTests.swift; sourceTree = ""; }; @@ -495,6 +497,7 @@ isa = PBXGroup; children = ( B501C03C208FC52400D1E58F /* LoginFieldsValidationTests.swift */, + D85C3881256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift */, ); path = Model; sourceTree = ""; @@ -1286,6 +1289,7 @@ BA53D64B24DFE07D001F1ABF /* WordpressAuthenticatorProvider.swift in Sources */, CE16177821B70C1A00B82A47 /* WordPressAuthenticatorDisplayTextTests.swift in Sources */, B501C048208FC79C00D1E58F /* LoginFacadeTests.m in Sources */, + D85C3882256E3FEC00D56E34 /* WordPressComSiteInfoTests.swift in Sources */, F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */, B501C046208FC6A700D1E58F /* WordPressAuthenticatorTests.swift in Sources */, ); diff --git a/WordPressAuthenticator/Model/WordPressComSiteInfo.swift b/WordPressAuthenticator/Model/WordPressComSiteInfo.swift index 8e9db64c7..2cbae4f47 100644 --- a/WordPressAuthenticator/Model/WordPressComSiteInfo.swift +++ b/WordPressAuthenticator/Model/WordPressComSiteInfo.swift @@ -21,6 +21,14 @@ public class WordPressComSiteInfo { /// public let hasJetpack: Bool + /// Indicates if Jetpack is active, or not. + /// + public let isJetpackActive: Bool + + /// Indicates if Jetpack is connected, or not. + /// + public let isJetpackConnected: Bool + /// URL of the Site's Blavatar. /// public let icon: String @@ -29,17 +37,28 @@ public class WordPressComSiteInfo { /// public let isWPCom: Bool + /// Inidcates wheter the site is WordPress, or not. + /// + public let isWP: Bool + + /// Inidcates whether the site exists, or not. + /// + public let exists: Bool + /// Initializes the current SiteInfo instance with a raw dictionary. /// public init(remote: [AnyHashable: Any]) { - name = remote["name"] as? String ?? "" - tagline = remote["description"] as? String ?? "" - url = remote["URL"] as? String ?? "" - hasJetpack = remote["hasJetpack"] as? Bool ?? false - icon = remote["icon.img"] as? String ?? "" - isWPCom = remote["isWordPressDotCom"] as? Bool ?? false - + name = remote["name"] as? String ?? "" + tagline = remote["description"] as? String ?? "" + url = remote["urlAfterRedirects"] as? String ?? "" + hasJetpack = remote["hasJetpack"] as? Bool ?? false + isJetpackActive = remote["isJetpackActive"] as? Bool ?? false + isJetpackConnected = remote["isJetpackConnected"] as? Bool ?? false + icon = remote["icon.img"] as? String ?? "" + isWPCom = remote["isWordPressDotCom"] as? Bool ?? false + isWP = remote["isWordPress"] as? Bool ?? false + exists = remote["exists"] as? Bool ?? false } } diff --git a/WordPressAuthenticatorTests/Model/WordPressComSiteInfoTests.swift b/WordPressAuthenticatorTests/Model/WordPressComSiteInfoTests.swift new file mode 100644 index 000000000..72f955f68 --- /dev/null +++ b/WordPressAuthenticatorTests/Model/WordPressComSiteInfoTests.swift @@ -0,0 +1,50 @@ +import XCTest +@testable import WordPressAuthenticator + +final class WordPressComSiteInfoTests: XCTestCase { + private var subject: WordPressComSiteInfo! + + override func setUp() { + subject = WordPressComSiteInfo(remote: mock()) + super.setUp() + } + + override func tearDown() { + super.tearDown() + subject = nil + } + + func testJetpackActiveMatchesExpectation() { + XCTAssertTrue(subject.isJetpackActive) + } + + func testHasJetpackMatchesExpectation() { + XCTAssertTrue(subject.hasJetpack) + } + + func testJetpackConnectedMatchesExpectation() { + XCTAssertTrue(subject.isJetpackConnected) + } + + func testWPComMatchesExpectation() { + XCTAssertFalse(subject.isWPCom) + } + + func testWPMatchesExpectation() { + XCTAssertTrue(subject.isWP) + } +} + +private extension WordPressComSiteInfoTests { + func mock() -> [AnyHashable: Any] { + return [ + "isJetpackActive": true, + "jetpackVersion": false, + "isWordPressDotCom": false, + "urlAfterRedirects": "https://somewhere.com", + "hasJetpack": true, + "isWordPress": true, + "isJetpackConnected": true + ] as [AnyHashable: Any] + } +}