-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompoundAnalyticsEngineTests.swift
More file actions
42 lines (36 loc) · 1.25 KB
/
CompoundAnalyticsEngineTests.swift
File metadata and controls
42 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// CompoundAnalyticsEngineTests.swift
// CTAnalyticsTests
//
// Created by Mark Pospesel on 7/19/21.
//
import XCTest
@testable import CTAnalytics
final class CompoundAnalyticsEngineTests: XCTestCase {
func testTrack() throws {
// Given
let sut = makeSUT()
let mock1 = try XCTUnwrap(sut.engines[0] as? MockAnalyticsEngine)
let mock2 = try XCTUnwrap(sut.engines[1] as? MockAnalyticsEngine)
let data = MockAnalyticsData()
let events = data.allEvents
XCTAssert(mock1.allEvents.isEmpty)
XCTAssert(mock2.allEvents.isEmpty)
// When
events.forEach { sut.track(event: $0) }
// Then
XCTAssertLogged(engine: mock1, data: data)
XCTAssertLogged(engine: mock2, data: data)
}
}
extension CompoundAnalyticsEngineTests {
func makeSUT(file: StaticString = #filePath, line: UInt = #line) -> CompoundAnalyticsEngine {
let mock1 = MockAnalyticsEngine()
let mock2 = MockAnalyticsEngine()
let sut = CompoundAnalyticsEngine(engines: [mock1, mock2])
trackForMemoryLeak(mock1, file: file, line: line)
trackForMemoryLeak(mock2, file: file, line: line)
trackForMemoryLeak(sut, file: file, line: line)
return sut
}
}