test: verify pallet label internal code dialog
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { nextTick } from 'vue'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import PalletLabelPrintDialog from './PalletLabelPrintDialog.vue'
|
||||
|
||||
const preparePalletLabels = vi.fn()
|
||||
|
||||
vi.mock('../api/platformLoadingLists', () => ({
|
||||
preparePalletLabels: (...args: unknown[]) => preparePalletLabels(...args),
|
||||
printPalletLabels: vi.fn(),
|
||||
}))
|
||||
|
||||
describe('PalletLabelPrintDialog', () => {
|
||||
beforeEach(() => {
|
||||
preparePalletLabels.mockReset().mockResolvedValue({
|
||||
planId: '10', planNo: 'LP-1', containerNo: 'HLCU1723867', totalCount: 2,
|
||||
groups: [{
|
||||
destinationWarehouseCode: 'ACY2', destinationWarehouseInternalCode: '101',
|
||||
destinationWarehouseName: 'ACY2', totalCount: 2,
|
||||
labels: [
|
||||
{ palletCode: 'HLCU1723867-101-001' },
|
||||
{ palletCode: 'HLCU1723867-101-002' },
|
||||
],
|
||||
}],
|
||||
})
|
||||
})
|
||||
|
||||
it('shows the server-generated internal code rule and both warehouse codes', async () => {
|
||||
const wrapper = mount(PalletLabelPrintDialog, {
|
||||
props: { planId: '10', warehouseId: '20' },
|
||||
global: {
|
||||
stubs: {
|
||||
AppDialog: { template: '<section><slot /></section>' },
|
||||
LoadErrorState: true,
|
||||
Printer: true,
|
||||
'el-button': { template: '<button @click="$emit(\'click\')"><slot /></button>' },
|
||||
'el-alert': { props: ['title'], template: '<p>{{ title }}</p>' },
|
||||
'el-radio-group': { template: '<div><slot /></div>' },
|
||||
'el-radio': { template: '<span><slot /></span>' },
|
||||
'el-select': { template: '<div><slot /></div>' },
|
||||
'el-option': true,
|
||||
'el-input-number': true,
|
||||
'el-table': { props: ['data'], template: '<div>{{ data }}</div>' },
|
||||
'el-table-column': true,
|
||||
},
|
||||
},
|
||||
})
|
||||
await wrapper.get('button').trigger('click')
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
|
||||
expect(preparePalletLabels).toHaveBeenCalledWith('10', '20')
|
||||
expect(wrapper.text()).toContain('HLCU1723867-FBA地址内部编号-三位序号')
|
||||
expect(wrapper.text()).toContain('ACY2')
|
||||
expect(wrapper.text()).toContain('101')
|
||||
expect(wrapper.text()).toContain('HLCU1723867-101-001')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user