Răsfoiți Sursa

Add some simple unit test.

Mateusz Samsel 6 ani în urmă
părinte
comite
2b6f46e0ec

+ 11 - 0
packages/ckeditor5-word-count/tests/manual/wordcount.html

@@ -0,0 +1,11 @@
+<style>
+	body {
+		width: 50vw;
+	}
+</style>
+<h2>Test editor</h2>
+<div id="editor">
+	Hello world
+</div>
+<div id="words">
+</div>

+ 33 - 0
packages/ckeditor5-word-count/tests/manual/wordcount.js

@@ -0,0 +1,33 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* globals console, window, document */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import WordCount from '../../src/wordcount';
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet, WordCount ],
+		toolbar: [
+			'heading', 'bold', 'italic', 'bulletedList', 'numberedList', 'blockQuote', 'link', 'undo', 'redo'
+		]
+	} )
+	.then( editor => {
+		window.editor = editor;
+
+		const wordCountPlugin = editor.plugins.get( 'WordCount' );
+		const wordCount = wordCountPlugin.getWordCountContainer();
+
+		wordCountPlugin.on( 'update', ( evt, payload ) => {
+			console.log( JSON.stringify( payload ) );
+		} );
+
+		document.getElementById( 'words' ).appendChild( wordCount );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 1 - 0
packages/ckeditor5-word-count/tests/manual/wordcount.md

@@ -0,0 +1 @@
+Test it