/* global cy */
import ListCard from './listCard.vue'
import moment from 'moment'
const today = moment().format('YYYY-MM-DD')
const createProps = (overrides = {}) => {
const baseProps = {
data: {
index: 0,
name: '测试',
time: today,
nested: {
label: '嵌套值'
}
},
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')
}
}
}
}
return {
...baseProps,
...overrides,
data: {
...baseProps.data,
...overrides.data
},
config: {
...baseProps.config,
...overrides.config,
map: {
...baseProps.config.map,
...overrides.config?.map
}
},
attr: {
...baseProps.attr,
...overrides.attr,
labelStyle: {
...baseProps.attr.labelStyle,
...overrides.attr?.labelStyle
}
},
itemAttr: {
...baseProps.itemAttr,
...overrides.itemAttr,
operation: overrides.itemAttr?.operation === undefined
? baseProps.itemAttr.operation
: overrides.itemAttr.operation
}
}
}
const mountListCard = (props = {}, slots = {}) => {
cy.mount(ListCard, {
props: createProps(props),
slots
})
}
describe('