Skip to content

Commit e221a4e

Browse files
committed
fix typo
1 parent cf0005c commit e221a4e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

MVVMPlayground/MVVMPlayground/Module/PhotoList/PhotoListViewModel.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class PhotoListViewModel {
1212

1313
let apiService: APIServiceProtocol
1414

15-
var photos: [Photo] = [Photo]()
15+
private var photos: [Photo] = [Photo]()
1616

17-
var cellViewMdoels: [PhotoListCellViewModel] = [PhotoListCellViewModel]()
17+
private var cellViewModels: [PhotoListCellViewModel] = [PhotoListCellViewModel]()
1818

1919
var numberOfCells: Int {
20-
return cellViewMdoels.count
20+
return cellViewModels.count
2121
}
2222

2323
var isAllowSegue: Bool = false
@@ -44,7 +44,7 @@ class PhotoListViewModel {
4444
}
4545

4646
func getCellViewModel( at indexPath: IndexPath ) -> PhotoListCellViewModel {
47-
return cellViewMdoels[indexPath.row]
47+
return cellViewModels[indexPath.row]
4848
}
4949

5050
func createCellViewModel( photo: Photo ) -> PhotoListCellViewModel {
@@ -73,7 +73,7 @@ class PhotoListViewModel {
7373
for photo in photos {
7474
vms.append( createCellViewModel(photo: photo) )
7575
}
76-
self.cellViewMdoels = vms
76+
self.cellViewModels = vms
7777
}
7878

7979
}

MVVMPlayground/MVVMPlaygroundTests/PhotoListViewModelTests.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class PhotoListViewModelTests: XCTestCase {
121121

122122
//Given a sut with fetched photos
123123
let indexPath = IndexPath(row: 0, section: 0)
124-
sut?.photos = PhotoStub().stubPhotos()
124+
sutFinishedFetchPhotos()
125125

126126
//When
127127
sut!.userPressed( at: indexPath )
@@ -136,7 +136,8 @@ class PhotoListViewModelTests: XCTestCase {
136136

137137
//Given a sut with fetched photos
138138
let indexPath = IndexPath(row: 4, section: 0)
139-
sut!.photos = PhotoStub().stubPhotos()
139+
sutFinishedFetchPhotos()
140+
140141
let expect = XCTestExpectation(description: "Alert message is shown")
141142
sut!.showAlertClosure = { message in
142143
expect.fulfill()
@@ -156,12 +157,10 @@ class PhotoListViewModelTests: XCTestCase {
156157
func test_get_cell_view_model() {
157158

158159
//Given a sut with fetched photos
159-
mockAPIService?.completePhotos = PhotoStub().stubPhotos()
160-
sut!.viewIsReady()
161-
mockAPIService?.fetchSuccess()
160+
sutFinishedFetchPhotos()
162161

163162
let indexPath = IndexPath(row: 1, section: 0)
164-
let testPhoto = sut!.photos[indexPath.row]
163+
let testPhoto = mockAPIService!.completePhotos![indexPath.row]
165164

166165
// When
167166
let vm = sut!.getCellViewModel(at: indexPath)
@@ -171,6 +170,12 @@ class PhotoListViewModelTests: XCTestCase {
171170

172171
}
173172

173+
private func sutFinishedFetchPhotos() {
174+
mockAPIService!.completePhotos = PhotoStub().stubPhotos()
175+
sut!.viewIsReady()
176+
mockAPIService!.fetchSuccess()
177+
}
178+
174179
}
175180

176181
class MockApiService: APIServiceProtocol {

0 commit comments

Comments
 (0)