From 837753560ba0d1f9f495ab5061cdea2762f5be5b Mon Sep 17 00:00:00 2001
From: chouchouji <70570907+chouchouji@users.noreply.github.com>
Date: Wed, 25 Dec 2024 17:24:57 +0800
Subject: [PATCH] test(ui/uploader): add remove button slot test case (#1837)
---
.../__snapshots__/index.spec.js.snap | 19 +++++++++++++++
.../src/uploader/__tests__/index.spec.js | 23 +++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap b/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap
index 2d3d1821db1..2113817ef05 100644
--- a/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap
+++ b/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap
@@ -101,6 +101,25 @@ exports[`test uploader progress 1`] = `
"
`;
+exports[`test uploader remove button slot 1`] = `
+"
+
+
+
https://varletjs.org/varlet/cat.jpg
remove
+
+
+
+
+
+
+
+
"
+`;
+
exports[`test uploader validation 1`] = `
"
diff --git a/packages/varlet-ui/src/uploader/__tests__/index.spec.js b/packages/varlet-ui/src/uploader/__tests__/index.spec.js
index f20ad06fe85..c2905d6d22a 100644
--- a/packages/varlet-ui/src/uploader/__tests__/index.spec.js
+++ b/packages/varlet-ui/src/uploader/__tests__/index.spec.js
@@ -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()
+})