wordcount.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module('plugins.wordcount');
  2. test('trace 1743 右键删除后计算字数', function () {
  3. var editor = te.obj[0];
  4. var range = te.obj[1];
  5. editor.setContent('<p>hello</p>');
  6. setTimeout(function () {
  7. range.setStart(editor.body.firstChild, 0).collapse(true).select();
  8. editor.execCommand('selectall');
  9. editor.execCommand('cleardoc');
  10. equal(editor.getContentLength(true), 0, '插入成功');
  11. start();
  12. }, 50);
  13. stop();
  14. });
  15. test('空格', function () {
  16. var editor = te.obj[0];
  17. var range = te.obj[1];
  18. editor.setContent(' \ufeff\u200B\t\t \n\n\t\n\b\t\n\b\u200B\t\t\n\n ');
  19. if (ua.browser.ie)
  20. equal(editor.getContentLength(true), 23, '清空后编辑器中23个空格');
  21. else
  22. equal(editor.getContentLength(true), 22, '清空后编辑器中22个空格');
  23. });
  24. test(' trace 3744 超出最大', function () {
  25. var div = document.body.appendChild(document.createElement('div'));
  26. div.id = 'ue';
  27. var editor = UE.getEditor('ue', {'UEDITOR_HOME_URL': '../../../', 'wordCount': true, 'maximumWords': 10,'initialContent':'','autoFloatEnabled': false});
  28. editor.ready(function () {
  29. expect(2);
  30. editor.addListener("wordcountoverflow", function () {
  31. ok(true, "超出最大");
  32. setTimeout(function () {
  33. UE.delEditor('ue');
  34. start();
  35. }, 500);
  36. });
  37. setTimeout(function () {
  38. editor.setContent('hello hello hello');
  39. equal(editor.getContentLength(true), 17, '仅统计字数')
  40. }, 50);
  41. });
  42. stop();
  43. });