Emit an event after previewer mounted
This commit is contained in:
parent
0d6cc52d23
commit
8ee01b7adb
@ -50,6 +50,7 @@
|
||||
|
||||
<script>
|
||||
import * as skinview3d from 'skinview3d';
|
||||
import { emit } from '../../js/event';
|
||||
import SkinSteve from '../../images/textures/steve.png';
|
||||
|
||||
export default {
|
||||
@ -103,6 +104,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
this.initPreviewer();
|
||||
emit('skinViewerMounted', this.$refs.previewer);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.viewer.dispose();
|
||||
|
@ -1,11 +1,16 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Previewer from '@/components/common/Previewer';
|
||||
import * as emitter from '@/js/event';
|
||||
import * as mockedSkinview3d from '../../__mocks__/skinview3d';
|
||||
|
||||
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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user