forked from wordpress-mobile/WordPress-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dec92e
commit 7570461
Showing
3 changed files
with
15 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,58 +20,50 @@ final class CompliancePopoverViewModelTests: CoreDataTestCase { | |
testDefaults?.removeObject(forKey: UserDefaults.didShowCompliancePopupKey) | ||
} | ||
|
||
func testDidTapSettingsUpdatesDefaults() { | ||
guard let defaults = try? XCTUnwrap(testDefaults) else { | ||
return | ||
} | ||
func testDidTapSettingsUpdatesDefaults() throws { | ||
let defaults = try XCTUnwrap(testDefaults) | ||
let sut = CompliancePopoverViewModel(defaults: defaults, contextManager: contextManager) | ||
sut.didTapSettings() | ||
XCTAssert(defaults.didShowCompliancePopup) | ||
} | ||
|
||
func testDidTapSettingsInvokesCoordinatorNavigation() { | ||
guard let defaults = try? XCTUnwrap(testDefaults) else { | ||
return | ||
} | ||
func testDidTapSettingsInvokesCoordinatorNavigation() throws { | ||
let defaults = try XCTUnwrap(testDefaults) | ||
let mockCoordinator = MockCompliancePopoverCoordinator() | ||
let sut = CompliancePopoverViewModel(defaults: defaults, contextManager: contextManager) | ||
sut.coordinator = mockCoordinator | ||
sut.didTapSettings() | ||
XCTAssertEqual(mockCoordinator.navigateToSettingsCallCount, 1) | ||
} | ||
|
||
func testDidTapSaveInvokesDismissWhenAccountIDExists() { | ||
guard let defaults = try? XCTUnwrap(testDefaults) else { | ||
return | ||
} | ||
func testDidTapSaveInvokesDismissWhenAccountIDExists() throws { | ||
let defaults = try XCTUnwrap(testDefaults) | ||
let mockCoordinator = MockCompliancePopoverCoordinator() | ||
UserSettings.defaultDotComUUID = account().uuid | ||
let sut = CompliancePopoverViewModel( | ||
defaults: defaults, | ||
contextManager: makeCoreDataStack() | ||
contextManager: contextManager | ||
) | ||
sut.coordinator = mockCoordinator | ||
sut.didTapSave() | ||
XCTAssertEqual(mockCoordinator.dismissCallCount, 1) | ||
XCTAssert(defaults.didShowCompliancePopup) | ||
} | ||
|
||
private func makeCoreDataStack() -> ContextManager { | ||
let contextManager = ContextManager.forTesting() | ||
let account = AccountBuilder(contextManager) | ||
private func account() -> WPAccount { | ||
return AccountBuilder(contextManager) | ||
.with(id: 1229) | ||
.with(username: "foobar") | ||
.with(email: "[email protected]") | ||
.with(authToken: "9384rj398t34j98") | ||
.build() | ||
UserSettings.defaultDotComUUID = account.uuid | ||
return contextManager | ||
} | ||
} | ||
|
||
private class MockCompliancePopoverCoordinator: CompliancePopoverCoordinatorProtocol { | ||
var navigateToSettingsCallCount = 0 | ||
var presentIfNeededCallCount = 0 | ||
var dismissCallCount = 0 | ||
private(set) var navigateToSettingsCallCount = 0 | ||
private(set) var presentIfNeededCallCount = 0 | ||
private(set) var dismissCallCount = 0 | ||
|
||
func presentIfNeeded() { | ||
presentIfNeededCallCount += 1 | ||
|