mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
test(NoticeBar): add more test cases
This commit is contained in:
parent
8ec96da204
commit
8a05cd529a
@ -7,3 +7,19 @@ exports[`icon slot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>Custom Right Icon</div>
|
</div>Custom Right Icon</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`should not scroll when content width > wrap width 1`] = `
|
||||||
|
<div role="alert" class="van-notice-bar">
|
||||||
|
<div role="marquee" class="van-notice-bar__wrap">
|
||||||
|
<div class="van-notice-bar__content" style="transition-duration: 0s;">foo</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`should scroll when content width > wrap width 1`] = `
|
||||||
|
<div role="alert" class="van-notice-bar">
|
||||||
|
<div role="marquee" class="van-notice-bar__wrap">
|
||||||
|
<div class="van-notice-bar__content" style="transition-duration: 2s; transform: translateX(-100px);">foo</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
@ -48,3 +48,49 @@ test('replay event', async () => {
|
|||||||
await later(50);
|
await later(50);
|
||||||
expect(wrapper.emitted('replay')).toBeTruthy();
|
expect(wrapper.emitted('replay')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should scroll when content width > wrap width ', async () => {
|
||||||
|
const wrapper = mount(NoticeBar, {
|
||||||
|
propsData: {
|
||||||
|
text: 'foo',
|
||||||
|
delay: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const wrap = wrapper.find('.van-notice-bar__wrap');
|
||||||
|
const content = wrapper.find('.van-notice-bar__content');
|
||||||
|
|
||||||
|
wrap.element.getBoundingClientRect = () => ({
|
||||||
|
width: 50,
|
||||||
|
});
|
||||||
|
content.element.getBoundingClientRect = () => ({
|
||||||
|
width: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
await later(50);
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not scroll when content width > wrap width ', async () => {
|
||||||
|
const wrapper = mount(NoticeBar, {
|
||||||
|
propsData: {
|
||||||
|
text: 'foo',
|
||||||
|
delay: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const wrap = wrapper.find('.van-notice-bar__wrap');
|
||||||
|
const content = wrapper.find('.van-notice-bar__content');
|
||||||
|
|
||||||
|
wrap.element.getBoundingClientRect = () => ({
|
||||||
|
width: 200,
|
||||||
|
});
|
||||||
|
content.element.getBoundingClientRect = () => ({
|
||||||
|
width: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
await later(50);
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user