抽屉内容
' }, global: { stubs: { ElDrawer: ElDrawerStub, ElButton: ElButtonStub }, directives: { loading: {} }, }, }) } describe('AppDrawer', () => { it('provides default cancel and confirm actions', async () => { const wrapper = mountDrawer() const buttons = wrapper.findAll('button') expect(buttons.map((button) => button.text())).toEqual(['取消', '确定']) await buttons[1].trigger('click') expect(wrapper.emitted('confirm')).toHaveLength(1) await buttons[0].trigger('click') expect(wrapper.emitted('cancel')).toHaveLength(1) expect(wrapper.emitted('update:modelValue')).toEqual([[false]]) }) it('prevents accidental closing while confirmation is submitting', () => { const wrapper = mountDrawer({ confirmLoading: true }) const drawer = wrapper.getComponent(ElDrawerStub) const cancelButton = wrapper.findAll('button')[0] expect(drawer.props('showClose')).toBe(false) expect(drawer.props('closeOnClickModal')).toBe(false) expect(drawer.props('closeOnPressEscape')).toBe(false) expect(cancelButton.attributes('disabled')).toBeDefined() }) it('keeps the drawer chrome fixed while long content scrolls in the body', () => { const source = readFileSync(resolve(process.cwd(), 'src/shared/components/AppDrawer.vue'), 'utf8') expect(source).toContain(':global(.app-drawer .el-drawer__body) { min-height: 0; overflow-y: auto;') expect(source).toContain('max-width: 94vw') }) })