Skip to content

Commit 087a91b

Browse files
committed
rework / refine ids for tests
1 parent 022f82e commit 087a91b

File tree

5 files changed

+140
-185
lines changed

5 files changed

+140
-185
lines changed

Tests/Fakes/FakeCollectionViewModel.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension XCTestCase {
2222
id: String = .random,
2323
sectionId: (Int) -> String = defaultSectionId,
2424
cellId: (Int, Int) -> String = defaultCellId,
25-
supplementaryViewId: (Int, Int) -> String = defaultCellId,
25+
supplementaryViewId: (Int, Int) -> String = defaultViewId,
2626
numSections: Int = Int.random(in: 2...15),
2727
numCells: Int? = nil,
2828
useCellNibs: Bool = false,
@@ -47,14 +47,14 @@ extension XCTestCase {
4747
function: function
4848
)
4949
}
50-
return CollectionViewModel(id: "collection_\(id)", sections: sections)
50+
return CollectionViewModel(id: id, sections: sections)
5151
}
5252

5353
@MainActor
5454
func fakeSectionViewModel(
5555
id: String = .random,
5656
cellId: (Int, Int) -> String = defaultCellId,
57-
supplementaryViewId: (Int, Int) -> String = defaultCellId,
57+
supplementaryViewId: (Int, Int) -> String = defaultViewId,
5858
sectionIndex: Int = 0,
5959
numCells: Int = Int.random(in: 1...20),
6060
useCellNibs: Bool = false,
@@ -98,7 +98,7 @@ extension XCTestCase {
9898
} : []
9999

100100
return SectionViewModel(
101-
id: "section_\(id)",
101+
id: id,
102102
cells: cells,
103103
header: header,
104104
footer: footer,
@@ -184,9 +184,13 @@ extension XCTestCase {
184184
}
185185

186186
private func defaultSectionId(_ index: Int) -> String {
187-
"\(index)"
187+
"section_\(index)"
188188
}
189189

190190
private func defaultCellId(_ sectionIndex: Int, _ itemIndex: Int) -> String {
191-
"\(sectionIndex)-\(itemIndex)"
191+
"cell_\(sectionIndex)_\(itemIndex)"
192+
}
193+
194+
private func defaultViewId(_ sectionIndex: Int, _ itemIndex: Int) -> String {
195+
"view_\(sectionIndex)_\(itemIndex)"
192196
}

0 commit comments

Comments
 (0)