ref: master
public/javascripts/tinymce/tests/plugins/wordcount.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
module("tinymce.plugins.Wordcount", { setupModule: function() { QUnit.stop(); tinymce.init({ selector: "textarea", add_unload_trigger: false, skin: false, wordcount_target_id: 'current-count', plugins: 'wordcount', init_instance_callback: function(ed) { window.editor = ed; QUnit.start(); } }); } }); test("Blank document has 0 words", function() { expect(1); editor.setContent(''); var result = editor.plugins.wordcount.getCount(); equal(result, 0); }); test("Simple word count", function() { expect(1); editor.setContent('<p>My sentence is this.</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 4); }); test("Does not count dashes", function() { expect(1); editor.setContent('<p>Something -- ok</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 2); }); test("Does not count asterisks, non-word characters", function() { expect(1); editor.setContent('<p>* something\n\u00b7 something else</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 3); }); test("Does not count numbers", function() { expect(1); editor.setContent('<p>Something 123 ok</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 2); }); test("Does not count htmlentities", function() { expect(1); editor.setContent('<p>It’s my life – – – don\'t you forget.</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 6); }); test("Counts hyphenated words as one word", function() { expect(1); editor.setContent('<p>Hello some-word here.</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 3); }); test("Counts words between blocks as two words", function() { expect(1); editor.setContent('<p>Hello</p><p>world</p>'); var result = editor.plugins.wordcount.getCount(); equal(result, 2); }); |