我正在尝试对根据鼠标悬停显示 v-card-actions 的 @mouseover 和 @mouseleave 事件进行单元测试。我在我的 vuejs2 webpack 应用程序中使用 vue-test-utils。这是我在网上找到的:vue-utlis 鼠标单击示例。提前感谢任何提供帮助的人
这是我的代码实际的 html 模板代码:
<v-card class="menuCard pa-1 elevation-2 f-basis-0 my-2"
@mouseover="isBlockAct = true" @mouseleave="isBlockAct = (!checked?
false:true)">
<v-checkbox v-model="checked" id="checkbox" class="diCheckbox ma-0" hide-
details></v-checkbox>
<v-card-actions class="myUpHere pa-0">
<v-layout row :class="{'isAct': isBlockAct, 'isNotAct': !isBlockAct}">
</v-card>
这是我在我的 spec.js 代码中尝试的:
describe("Over event", () => {
it("shows the icons if the card is over or not", () => {
const wrapper = mount(MenuRepasRecetteCard, {
propsData: {}
});
wrapper.find(".menuCard").trigger("mouseover");
expect(wrapper.find(".isAct").text()).contain("remove_red_eye");
});