'How can I fix this error in Mokito? Wanted but not invoked
this is the real function : onMapLoaded()
override fun onMapLoaded(isWorking: Boolean) {
if (isWorking) {
activeArea?.let { interactor?.fetchHeatMapTiles(it.id) }
} else {
interactor?.fetchReservationCapacities()
}
if (activeArea != null) {
view?.showArea()
}
if (view?.hasLocationPermission() == true) {
locateMe()
}
}
These is the basic settings for testing
private lateinit var view: MapContract.View
private lateinit var interactor: MapContract.Interactor
private lateinit var presenter: MapPresenter
@Before
override fun setup() {
super.setup()
view = mock()
interactor = mock()
presenter = MapPresenter(view, interactor)
}
and this is my test function:
@Test
fun `Presenter should show user's current location immediately when map loaded`() {
val mockedPresenter = mock<MapPresenter>()
whenever(mockedPresenter.onMapLoaded(false)).thenCallRealMethod()
whenever(view.hasLocationPermission()).thenReturn(true)
mockedPresenter.onMapLoaded(false)
verify(mockedPresenter, Times(1)).locateMe()
}
But I get this error:
Please help me fix this bug
I want to make sure that the locateMe() function is executed But the test fails and is not run at all
Solution 1:[1]
you just need to remove line-height and use padding instead for spacing purpose
ul {
list-style: none;
width: 360px;
}
li {
padding: 8px 16px;
display: inline-block;
vertical-align: baseline;
min-height: 35px;
background: #000000;
width: 259px;
margin-right: 10px;
text-align: center;
border-bottom: 2px solid #fff;
}
a {
color: #fff
}
Solution 2:[2]
Make similar changes to your CSS as below:
ul {
list-style: none;
width: 60px;
margin: auto;
}
li {
display: inline-block;
vertical-align: baseline;
height: 35px;
line-height: 35px;
background: #000000;
width: 159px;
overflow: hidden;
margin-right: 10px;
text-align: center;
border-bottom: 2px solid #fff;
}
a {
color: #fff;
}
Solution 3:[3]
You could use flex on the ul.
This snippet removes the line-height setting as that made things too big.
It adds some padding to space the items out a bit.
ul {
list-style: none;
width: 360px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
li {
display: inline-block;
background: #000000;
width: 259px;
margin-right: 10px;
text-align: center;
border-bottom: 2px solid #fff;
padding: 10px;
}
a {
color: #fff
}
<ul>
<li> <a href="#">Menu item 1 </a> </li>
<li> <a href="#">Menu item 1 </a> </li>
<li> <a href="#">Duck sauce and cheesecake recipe for special people </a> </li>
<li> <a href="#">Menu item 1 </a> </li>
<li> <a href="#">Menu item 1 </a> </li>
</ul>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Junaid Shaikh |
| Solution 2 | minabagheri |
| Solution 3 | A Haworth |

