@@ -38,7 +38,7 @@ class CustomListActionUseCaseTest {
38
38
}
39
39
40
40
@Test
41
- fun `give action create when successful should return created result ` () = runTest {
41
+ fun `create action should return success when ok ` () = runTest {
42
42
// Arrange
43
43
val name = " test"
44
44
val locationCode = " AB"
@@ -81,7 +81,7 @@ class CustomListActionUseCaseTest {
81
81
}
82
82
83
83
@Test
84
- fun `give action create when list name already exits should return error ` () = runTest {
84
+ fun `create action should return error when name already exists ` () = runTest {
85
85
// Arrange
86
86
val name = " test"
87
87
val locationCode = " AB"
@@ -101,7 +101,7 @@ class CustomListActionUseCaseTest {
101
101
}
102
102
103
103
@Test
104
- fun `give action rename when successful should return rename result ` () = runTest {
104
+ fun `rename action should return success when ok ` () = runTest {
105
105
// Arrange
106
106
val name = " test"
107
107
val newName = " test2"
@@ -121,7 +121,7 @@ class CustomListActionUseCaseTest {
121
121
}
122
122
123
123
@Test
124
- fun `give action rename when list name already exists should return error ` () = runTest {
124
+ fun `rename action should return error when name already exists` () = runTest {
125
125
// Arrange
126
126
val name = " test"
127
127
val newName = " test2"
@@ -144,7 +144,7 @@ class CustomListActionUseCaseTest {
144
144
}
145
145
146
146
@Test
147
- fun `give action delete when successful should return delete result ` () = runTest {
147
+ fun `delete action should return successful with deleted list ` () = runTest {
148
148
// Arrange
149
149
val mockCustomList: CustomList = mockk()
150
150
val mockLocation: GeographicLocationConstraint .Country = mockk()
@@ -173,46 +173,45 @@ class CustomListActionUseCaseTest {
173
173
}
174
174
175
175
@Test
176
- fun `give action update locations when successful should return locations changed result` () =
177
- runTest {
178
- // Arrange
179
- val name = " test"
180
- val oldLocationCodes = listOf (" AB" , " CD" )
181
- val newLocationCodes = listOf (" EF" , " GH" )
182
- val oldLocations: ArrayList <GeographicLocationConstraint > =
183
- arrayListOf (
184
- GeographicLocationConstraint .Country (" AB" ),
185
- GeographicLocationConstraint .Country (" CD" )
186
- )
187
- val customListId = " 1"
188
- val customList = CustomList (id = customListId, name = name, locations = oldLocations)
189
- val action =
190
- CustomListAction .UpdateLocations (
191
- customListId = customListId,
192
- locations = newLocationCodes
193
- )
194
- val expectedResult =
195
- Result .success(
196
- CustomListResult .LocationsChanged (
197
- name = name,
198
- undo = action.not (locations = oldLocationCodes)
199
- )
176
+ fun `update locations action should return success with changed locations` () = runTest {
177
+ // Arrange
178
+ val name = " test"
179
+ val oldLocationCodes = listOf (" AB" , " CD" )
180
+ val newLocationCodes = listOf (" EF" , " GH" )
181
+ val oldLocations: ArrayList <GeographicLocationConstraint > =
182
+ arrayListOf (
183
+ GeographicLocationConstraint .Country (" AB" ),
184
+ GeographicLocationConstraint .Country (" CD" )
185
+ )
186
+ val customListId = " 1"
187
+ val customList = CustomList (id = customListId, name = name, locations = oldLocations)
188
+ val action =
189
+ CustomListAction .UpdateLocations (
190
+ customListId = customListId,
191
+ locations = newLocationCodes
192
+ )
193
+ val expectedResult =
194
+ Result .success(
195
+ CustomListResult .LocationsChanged (
196
+ name = name,
197
+ undo = action.not (locations = oldLocationCodes)
200
198
)
201
- coEvery { mockCustomListsRepository.getCustomListById(customListId) } returns customList
199
+ )
200
+ coEvery { mockCustomListsRepository.getCustomListById(customListId) } returns customList
202
201
203
- coEvery {
204
- mockCustomListsRepository.updateCustomListLocationsFromCodes(
205
- customListId,
206
- newLocationCodes
207
- )
208
- } returns UpdateCustomListResult .Ok
202
+ coEvery {
203
+ mockCustomListsRepository.updateCustomListLocationsFromCodes(
204
+ customListId,
205
+ newLocationCodes
206
+ )
207
+ } returns UpdateCustomListResult .Ok
209
208
210
- // Act
211
- val result = customListActionUseCase.performAction(action)
209
+ // Act
210
+ val result = customListActionUseCase.performAction(action)
212
211
213
- // Assert
214
- assertEquals(expectedResult, result)
215
- }
212
+ // Assert
213
+ assertEquals(expectedResult, result)
214
+ }
216
215
217
216
companion object {
218
217
private const val RELAY_LIST_EXTENSIONS =
0 commit comments