我有以下代码:
companion object {
val COMPARATOR = object : DiffUtil.ItemCallback<Reservation>() {
override fun areContentsTheSame(oldItem: Reservation, newItem: Reservation): Boolean =
oldItem == newItem
override fun areItemsTheSame(oldItem: Reservation, newItem: Reservation): Boolean =
oldItem.id == newItem.id
}
}
我需要像这样将模拟传递给shallowMount:
this.$vs.loading()
....
this.$vs.loading.close()
但是我该如何嘲笑const vs = {
loading: jest.fn()
}
mocks: {
$vs: vs
}
和loading
?
我使用close
来模拟loading: jest.fn()
。如何在loading()
属性中模拟close()
?
答案 0 :(得分:0)
您可以将模拟属性附加到模拟函数本身:
const vs = {
loading: jest.fn()
}
vs.loading.close = jest.fn()