From e201bc55ee5670630b20e7d611da18f347b8b8ef Mon Sep 17 00:00:00 2001 From: JSparow Date: Mon, 21 Sep 2020 21:29:09 +0800 Subject: [PATCH] feat(SidebarItem): add title slot (#7220) --- src/sidebar-item/index.js | 2 +- src/sidebar/README.md | 6 ++++++ src/sidebar/README.zh-CN.md | 6 ++++++ .../test/__snapshots__/index.spec.js.snap | 9 +++++++++ src/sidebar/test/index.spec.js | 19 +++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/sidebar/test/__snapshots__/index.spec.js.snap diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js index 54d587f1d..058eb77d5 100644 --- a/src/sidebar-item/index.js +++ b/src/sidebar-item/index.js @@ -43,7 +43,7 @@ export default createComponent({ onClick={this.onClick} >
- {this.title} + {this.slots('title') ?? this.title} +
Title Slot + +
+
+`; diff --git a/src/sidebar/test/index.spec.js b/src/sidebar/test/index.spec.js index a3e533410..966eb72d0 100644 --- a/src/sidebar/test/index.spec.js +++ b/src/sidebar/test/index.spec.js @@ -76,3 +76,22 @@ test('without parent', () => { expect(err).toBeTruthy(); } }); + +test('title slot', () => { + const wrapper = mount({ + template: ` + + + + + + `, + data() { + return { + active: 0, + }; + }, + }); + + expect(wrapper).toMatchSnapshot(); +});