scene-component.test.ts 821 B

123456789101112131415161718192021222324252627
  1. import { mount } from '@vue/test-utils'
  2. import { WebGLRenderer } from 'three'
  3. var glContext = require('gl')(1, 1) //headless-gl
  4. var Canvas = require('canvas')
  5. var canvasGL = new Canvas.Canvas(window.innerWidth, window.innerHeight)
  6. canvasGL.addEventListener = function (event, func, bind_) {} // mock function to avoid errors inside THREE.WebGlRenderer()
  7. import { Scene } from './component'
  8. var width = 64
  9. var height = 64
  10. var gl = require('gl')(width, height, { preserveDrawingBuffer: true })
  11. const canvas = document.createElement('canvas')
  12. test('mount component', async () => {
  13. expect(Scene).toBeTruthy()
  14. const wrapper = mount(Scene, {
  15. global: {
  16. provide: {
  17. renderer: new WebGLRenderer({ canvas, context: gl }),
  18. },
  19. },
  20. })
  21. console.log(wrapper.vm)
  22. expect(wrapper.vm).toBeTruthy()
  23. })