Skip to content

Commit

Permalink
test(ui/uploader): add remove button slot test case
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed Dec 25, 2024
1 parent 859701d commit ed0428c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ exports[`test uploader progress 1`] = `
</div>"
`;
exports[`test uploader remove button slot 1`] = `
"<div class="var-uploader var--box">
<div class="var-uploader__file-list">
<div class="var-uploader__file var-elevation--2">
<div class="var-uploader__file-name">https://varletjs.org/varlet/cat.jpg</div>remove<img role="img" class="var-uploader__file-cover" src="https://varletjs.org/varlet/cat.jpg">
<div class="var-uploader__file-indicator">
<div class="var-uploader__progress"></div>
</div>
</div>
<div class="var-uploader--outline-none var-uploader__action var-elevation--2" tabindex="0"><input type="file" class="var-uploader__action-input" accept="image/*"><i class="var-icon var-icon--set var-icon-plus var-uploader__action-icon" style="transition-duration: 0ms;" var-uploader-cover=""></i>
<div class="var-hover-overlay"></div>
</div>
</div>
<!--v-if-->
<!--teleport start-->
<!--teleport end-->
</div>"
`;
exports[`test uploader validation 1`] = `
"<div class="var-uploader var--box">
<div class="var-uploader__file-list">
Expand Down
23 changes: 23 additions & 0 deletions packages/varlet-ui/src/uploader/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,26 @@ test('test uploader validation with zod', async () => {
wrapper.unmount()
mockRestore()
})

test('test uploader remove button slot', async () => {
const { mockRestore: mockRestoreStubs } = mockStubs()

const wrapper = mount(VarUploader, {
props: {
modelValue: [
{
url: 'https://varletjs.org/varlet/cat.jpg',
cover: 'https://varletjs.org/varlet/cat.jpg',
},
],
},
slots: {
'remove-button': () => 'remove',
},
})

expect(wrapper.html()).toMatchSnapshot()

mockRestoreStubs()
wrapper.unmount()
})

0 comments on commit ed0428c

Please sign in to comment.