diy-icongroup.spec.js 684 B

12345678910111213
  1. const simulate = require('miniprogram-simulate')
  2. test('components/diy-icongroup', () => {
  3. const id = simulate.load('/components/diy-icongroup') // 此处必须传入绝对路径
  4. const comp = simulate.render(id) // 渲染成自定义组件树实例
  5. const parent = document.createElement('parent-wrapper') // 创建父亲节点
  6. comp.attach(parent) // attach 到父亲节点上,此时会触发自定义组件的 attached 钩子
  7. const view = comp.querySelector('.index') // 获取子组件 view
  8. expect(view.dom.innerHTML).toBe('index.properties') // 测试渲染结果
  9. expect(window.getComputedStyle(view.dom).color).toBe('green') // 测试渲染结果
  10. })