File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
WooCommerce/WooCommerceTests/Authentication Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 11import XCTest
2+ import Yosemite
3+ import TestKit
24@testable import WooCommerce
35
46final class JetpackErrorViewModelTests : XCTestCase {
57
8+ private var analyticsProvider : MockAnalyticsProvider !
9+ private var analytics : WooAnalytics !
10+
11+ override func setUp( ) {
12+ super. setUp ( )
13+ analyticsProvider = MockAnalyticsProvider ( )
14+ analytics = WooAnalytics ( analyticsProvider: analyticsProvider)
15+ }
16+
17+ override func tearDown( ) {
18+ analytics = nil
19+ analyticsProvider = nil
20+ super. tearDown ( )
21+ }
22+
623 func test_viewmodel_provides_expected_image( ) {
724 // Given
825 let viewModel = JetpackErrorViewModel ( siteURL: Expectations . url)
@@ -57,6 +74,20 @@ final class JetpackErrorViewModelTests: XCTestCase {
5774 // Then
5875 XCTAssertEqual ( secondaryButtonTitle, Expectations . secondaryButtonTitle)
5976 }
77+
78+ func test_viewModel_logs_an_event_when_viewDidLoad_is_triggered( ) throws {
79+ // Given
80+ let viewModel = JetpackErrorViewModel ( siteURL: Expectations . url, analytics: analytics)
81+
82+ assertEmpty ( analyticsProvider. receivedEvents)
83+
84+ // When
85+ viewModel. viewDidLoad ( in: nil )
86+
87+ // Then
88+ let firstEvent = try XCTUnwrap ( analyticsProvider. receivedEvents. first)
89+ XCTAssertEqual ( firstEvent, " login_jetpack_required_screen_viewed " )
90+ }
6091}
6192
6293
You can’t perform that action at this time.
0 commit comments