Skip to content

Commit 4f34757

Browse files
committed
test: add ribbon test
1 parent 65c4666 commit 4f34757

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

components/badge/__tests__/index.test.js

+74
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { mount } from '@vue/test-utils';
22
import Badge from '../index';
3+
import mountTest from '../../../tests/shared/mountTest';
34

45
import { asyncExpect } from '@/tests/utils';
56
describe('Badge', () => {
@@ -147,3 +148,76 @@ describe('Badge', () => {
147148
expect(wrapper.html()).toMatchSnapshot();
148149
});
149150
});
151+
152+
describe('Ribbon', () => {
153+
mountTest(Badge.Ribbon);
154+
155+
describe('placement', () => {
156+
it('works with `start` & `end` placement', () => {
157+
const wrapperStart = mount({
158+
render() {
159+
return (
160+
<Badge.Ribbon placement="start">
161+
<div />
162+
</Badge.Ribbon>
163+
);
164+
},
165+
});
166+
167+
expect(wrapperStart.findAll('.ant-ribbon-placement-start').length).toEqual(1);
168+
169+
const wrapperEnd = mount({
170+
render() {
171+
return (
172+
<Badge.Ribbon placement="end">
173+
<div />
174+
</Badge.Ribbon>
175+
);
176+
},
177+
});
178+
expect(wrapperEnd.findAll('.ant-ribbon-placement-end').length).toEqual(1);
179+
});
180+
});
181+
182+
describe('color', () => {
183+
it('works with preset color', () => {
184+
const wrapper = mount({
185+
render() {
186+
return (
187+
<Badge.Ribbon color="green">
188+
<div />
189+
</Badge.Ribbon>
190+
);
191+
},
192+
});
193+
expect(wrapper.findAll('.ant-ribbon-color-green').length).toEqual(1);
194+
});
195+
});
196+
197+
describe('text', () => {
198+
it('works with string', () => {
199+
const wrapper = mount({
200+
render() {
201+
return (
202+
<Badge.Ribbon text="cool">
203+
<div />
204+
</Badge.Ribbon>
205+
);
206+
},
207+
});
208+
expect(wrapper.find('.ant-ribbon').text()).toEqual('cool');
209+
});
210+
it('works with element', () => {
211+
const wrapper = mount({
212+
render() {
213+
return (
214+
<Badge.Ribbon text={<span class="cool" />}>
215+
<div />
216+
</Badge.Ribbon>
217+
);
218+
},
219+
});
220+
expect(wrapper.findAll('.cool').length).toEqual(1);
221+
});
222+
});
223+
});

0 commit comments

Comments
 (0)