/* global cy */ import ListCard from './listCard.vue' import moment from 'moment' const mount = () => { cy.mount(ListCard, { props: { data: { index: 0, name: '测试', time: moment().format('YYYY-MM-DD') }, config: { map: { index: '序号', name: '名称', time: '时间' }, title: '测试ListCard' }, attr: { column: 1, direction: 'horizontal', labelStyle: { color: '#303D67', fontSize: '14px', fontWeight: 400, width: 'auto' } }, itemAttr: { operation: { name: { type: 'primary', text: '修改名称', method: cy.spy().as('clickHandler') } } } } }) } describe(' 组件', () => { it('挂载组件正确', () => { mount() cy.get('.list-card').should('exist') cy.get('.el-descriptions__title').contains('测试ListCard') }) it('标题正确渲染', () => { mount() cy.get('.el-descriptions__title').contains('测试ListCard') }) it('表单内容正确渲染', () => { mount() cy.get('.el-descriptions__cell').should('have.length', 3) cy.get('.el-descriptions__content').contains(moment().format('YYYY-MM-DD')) }) it('表单内容正确渲染', () => { mount() cy.get('.el-descriptions__cell').should('have.length', 3) cy.get('.el-descriptions__content').contains(moment().format('YYYY-MM-DD')) }) it('修改事件正确触发', () => { mount() cy.get('.el-button--primary').click() cy.get('@clickHandler').should('have.been.called') }) })