import Vue from 'vue' import { mount } from '@vue/test-utils' import Previewer from '@/components/Previewer.vue' import * as emitter from '@/scripts/event' import * as mockedSkinview3d from '../__mocks__/skinview3d' type Viewer = Vue & { viewer: mockedSkinview3d.SkinViewer } interface Handles { handles: { run: { paused: boolean } walk: { paused: boolean } rotate: { paused: boolean } } } test('initialize skinview3d', () => { const stub = jest.fn() emitter.on('skinViewerMounted', stub) const wrapper = mount(Previewer) expect(wrapper.vm.viewer).toBeInstanceOf(mockedSkinview3d.SkinViewer) expect(wrapper.vm.viewer.camera.position.z).toBe(70) expect(stub).toBeCalledWith(expect.any(HTMLElement)) }) test('dispose viewer before destroy', () => { const wrapper = mount(Previewer) wrapper.destroy() expect(wrapper.vm.viewer.disposed).toBeTrue() }) test('skin URL should be updated', () => { const wrapper = mount(Previewer) wrapper.setProps({ skin: 'abc' }) expect(wrapper.vm.viewer.skinUrl).toBe('abc') }) test('cape URL should be updated', () => { const wrapper = mount(Previewer) wrapper.setProps({ cape: 'abc' }) expect(wrapper.vm.viewer.capeUrl).toBe('abc') }) test('`footer` slot', () => { const wrapper = mount(Previewer, { slots: { footer: '