editor-toolbar-selection.test.js 828 B

12345678910111213141516171819202122232425262728293031
  1. const assert = require('assert')
  2. const fs = require('fs')
  3. const source = fs.readFileSync(
  4. require('path').resolve(__dirname, '../src/components/editor/index.vue'),
  5. 'utf8'
  6. )
  7. assert.match(
  8. source,
  9. /onCreated\s*:\s*\(editor\)\s*=>\s*\{\s*editor\.focus\(\)/,
  10. 'editor must initialize a Slate selection after creation so toolbar buttons are enabled'
  11. )
  12. assert.match(
  13. source,
  14. /data\(\)\s*\{\s*return\s*\{\}\s*\}/,
  15. 'wangEditor instances must stay outside Vue 2 reactive data to avoid revoked Slate proxies'
  16. )
  17. assert.match(
  18. source,
  19. /const editor\s*=\s*createEditor[\s\S]*this\._editor\s*=\s*editor/,
  20. 'editor must be stored as a non-reactive private instance field'
  21. )
  22. assert.match(
  23. source,
  24. /height:\s*600px\s*!important/,
  25. 'editor container must be at least 300px high for modal and hoverbar positioning'
  26. )