cmvr-wms/ruoyi-ui-vue3/tests/runtime/purchase-numeric-alignment.spec.js

16 lines
1.0 KiB
JavaScript
Raw Normal View History

import {expect,it} from 'vitest'
import {mount} from '@vue/test-utils'
import ElementPlus from 'element-plus'
import Cell from '../../src/components/PurchaseSheet/Cell.vue'
it('actual and quoted unit prices use the same numeric cell in read-only and active editors',async()=>{
const row={actualUnitPrice:12.34,finalUnitPrice:15,quantity:2}
const owner={cellError:()=>'',editableCell:()=>true,readonly:()=>false,fieldLocked:()=>false,displayCell:(r,f)=>r[f],isEditing:true,saving:false}
for(const field of ['actualUnitPrice','finalUnitPrice','quantity']){
const wrapper=mount(Cell,{props:{row,column:{field,label:field},index:0,owner,active:false},global:{plugins:[ElementPlus]}})
expect(wrapper.get('.sheet-cell').classes()).toContain('cell-numeric')
expect(wrapper.get('.sheet-value').text()).toBe(String(row[field]))
await wrapper.setProps({active:true});expect(wrapper.get('.sheet-cell').classes()).toContain('cell-numeric');expect(wrapper.find('input').exists()).toBe(true)
wrapper.unmount()
}
})