Skip to content

Commit 3fd19d4

Browse files
SimeonCSimeonC
authored andcommitted
test(taTools): Adds the wordcount and charcount tests
1 parent 1a77b3b commit 3fd19d4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/taTools.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,32 @@ describe('taTools test tool actions', function(){
309309
testAllButtons();
310310
});
311311

312+
describe('test count buttons', function(){
313+
beforeEach(module('textAngular'));
314+
var buttons;
315+
beforeEach(inject(function (_$compile_, _$rootScope_, $document, textAngularManager, _$window_) {
316+
$window = _$window_;
317+
$rootScope = _$rootScope_;
318+
$rootScope.htmlcontent = '<p>Test Content <b>that</b> <u>should</u> be cleared</p><h1>Test Other Tags</h1><ul><li>Test <b>1</b></li><li>Test 2</li></ul>';
319+
element = _$compile_('<text-angular name="test" ng-model="htmlcontent" ta-toolbar="[[\'wordcount\',\'charcount\']]"></text-angular>')($rootScope);
320+
$rootScope.$digest();
321+
editorScope = textAngularManager.retrieveEditor('test').scope;
322+
buttons = element.children()[0].childNodes[0];
323+
textAngularManager.retrieveEditor('test').editorFunctions.updateSelectedStyles();
324+
$rootScope.$digest();
325+
}));
326+
327+
it('word count should be 13', function(){
328+
expect(buttons.childNodes[0].innerHTML).toBe('Words:13');
329+
expect(editorScope.wordcount).toBe(13);
330+
});
331+
332+
it('char count should be 62', function(){
333+
expect(buttons.childNodes[1].innerHTML).toBe('Characters:62');
334+
expect(editorScope.charcount).toBe(62);
335+
});
336+
});
337+
312338
describe('test clear button', function(){
313339
beforeEach(module('textAngular'));
314340
beforeEach(inject(function (_$compile_, _$rootScope_, $document, textAngularManager, _$window_) {

0 commit comments

Comments
 (0)