diy-icongroup.spec.js 1.3 KB

1234567891011121314151617181920212223242526272829
  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. // })
  11. const path = require('path')
  12. const expect = require('chai').expect
  13. describe('component', () => {
  14. it ('should run successfully', () => {
  15. // 此处直接使用 simulate 或者 window.simulate 即可,不需要再做 require
  16. const id = simulate.load(path.resolve(__dirname, 'component/diy-icongroup'))
  17. const comp = simulate.render(id, {prop: 'index.test.properties'})
  18. comp.attach(document.body) // 挂载在 body 下面
  19. expect(simulate.match(comp.dom, '<wx-view class="main--index">index.test.properties</wx-view>')).to.equal(true)
  20. })
  21. })