|
|
@@ -2,59 +2,25 @@ import { mount } from '@vue/test-utils';
|
|
|
import Video from '../index.vue';
|
|
|
|
|
|
describe('Video', () => {
|
|
|
- test('base Video', () => {
|
|
|
- const wrapper = mount(Video);
|
|
|
- const rate = wrapper.find('.nut-video');
|
|
|
- expect(rate.exists()).toBe(true);
|
|
|
- });
|
|
|
- test('should be displayed after setting the source src and type', () => {
|
|
|
+ test('video base info', () => {
|
|
|
const wrapper = mount(Video, {
|
|
|
props: {
|
|
|
source: {
|
|
|
src: 'xxx.mp4',
|
|
|
- type: 'video/mp4'
|
|
|
+ type: 'video/mp4',
|
|
|
+ poster:
|
|
|
+ 'https://img12.360buyimg.com/ling/s345x208_jfs/t1/168105/33/8417/54825/603df06dEfcddc4cb/21f9f5d0a1b3dad4.jpg.webp'
|
|
|
},
|
|
|
options: {
|
|
|
- controls: true
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- expect(wrapper.html()).toContain('src');
|
|
|
- expect(wrapper.html()).toContain('type');
|
|
|
- expect(wrapper.html()).toContain('controls');
|
|
|
- });
|
|
|
- test('should be displayed after setting the options autoplay and muted and loop', () => {
|
|
|
- const wrapper = mount(Video, {
|
|
|
- props: {
|
|
|
- options: {
|
|
|
+ controls: true,
|
|
|
autoplay: true,
|
|
|
muted: true,
|
|
|
+ playsinline: true,
|
|
|
loop: true
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- expect(wrapper.html()).toContain('autoplay');
|
|
|
- expect(wrapper.html()).toContain('muted');
|
|
|
- expect(wrapper.html()).toContain('loop');
|
|
|
- });
|
|
|
- test('should be displayed after setting the options poster and playsinline', () => {
|
|
|
- const wrapper = mount(Video, {
|
|
|
- props: {
|
|
|
- options: {
|
|
|
- poster: 'xxx.png',
|
|
|
- playsinline: true
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- expect(wrapper.html()).toContain('xxx.png');
|
|
|
- expect(wrapper.html()).toContain('playsinline');
|
|
|
- });
|
|
|
- test('should be displayed after setting the click', () => {
|
|
|
- const wrapper = mount(Video);
|
|
|
- const _html1 = wrapper.find('.show-control');
|
|
|
- expect(_html1.exists()).toBe(true);
|
|
|
- wrapper.find('.control-play-btn').trigger('click');
|
|
|
- const _html2 = wrapper.find('.hide-control');
|
|
|
- expect(_html2.exists()).toBe(false);
|
|
|
+ expect(wrapper.find<HTMLElement>('.nut-video source').html()).toContain('xxx.mp4');
|
|
|
+ expect(wrapper.html()).toMatchSnapshot();
|
|
|
});
|
|
|
});
|