Explorar el Código

Internal: Added test coverage.

Marek Lewandowski hace 6 años
padre
commit
b815841823

+ 56 - 0
packages/ckeditor5-special-characters/tests/specialcharactersarrows.js

@@ -0,0 +1,56 @@
+/**
+ * @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 document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import SpecialCharacters from '../src/specialcharacters';
+import SpecialCharactersArrows from '../src/specialcharactersarrows';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'SpecialCharactersArrows', () => {
+	testUtils.createSinonSandbox();
+
+	let addItemsSpy, addItemsFirstCallArgs;
+
+	beforeEach( () => {
+		const editorElement = document.createElement( 'div' );
+
+		addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );
+
+		document.body.appendChild( editorElement );
+		return ClassicTestEditor
+			.create( editorElement, {
+				plugins: [ SpecialCharacters, SpecialCharactersArrows ]
+			} )
+			.then( () => {
+				addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
+			} );
+	} );
+
+	afterEach( () => {
+		addItemsSpy.restore();
+	} );
+
+	it( 'adds new items', () => {
+		expect( addItemsSpy.callCount ).to.equal( 1 );
+	} );
+
+	it( 'properly names the category', () => {
+		expect( addItemsFirstCallArgs[ 0 ] ).to.be.equal( 'Arrows' );
+	} );
+
+	it( 'adds proper characters', () => {
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			title: 'rightwards double arrow',
+			character: '⇒'
+		} );
+
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			title: 'rightwards arrow to bar',
+			character: '⇥'
+		} );
+	} );
+} );

+ 56 - 0
packages/ckeditor5-special-characters/tests/specialcharacterscurrency.js

@@ -0,0 +1,56 @@
+/**
+ * @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 document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import SpecialCharacters from '../src/specialcharacters';
+import SpecialCharactersCurrency from '../src/specialcharacterscurrency';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'SpecialCharactersCurrency', () => {
+	testUtils.createSinonSandbox();
+
+	let addItemsSpy, addItemsFirstCallArgs;
+
+	beforeEach( () => {
+		const editorElement = document.createElement( 'div' );
+
+		addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );
+
+		document.body.appendChild( editorElement );
+		return ClassicTestEditor
+			.create( editorElement, {
+				plugins: [ SpecialCharacters, SpecialCharactersCurrency ]
+			} )
+			.then( () => {
+				addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
+			} );
+	} );
+
+	afterEach( () => {
+		addItemsSpy.restore();
+	} );
+
+	it( 'adds new items', () => {
+		expect( addItemsSpy.callCount ).to.equal( 1 );
+	} );
+
+	it( 'properly names the category', () => {
+		expect( addItemsFirstCallArgs[ 0 ] ).to.be.equal( 'Currency' );
+	} );
+
+	it( 'adds proper characters', () => {
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: '¢',
+			title: 'Cent sign'
+		} );
+
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: '₿',
+			title: 'Bitcoin sign'
+		} );
+	} );
+} );

+ 56 - 0
packages/ckeditor5-special-characters/tests/specialcharacterslatin.js

@@ -0,0 +1,56 @@
+/**
+ * @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 document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import SpecialCharacters from '../src/specialcharacters';
+import SpecialCharactersLatin from '../src/specialcharacterslatin';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'SpecialCharactersLatin', () => {
+	testUtils.createSinonSandbox();
+
+	let addItemsSpy, addItemsFirstCallArgs;
+
+	beforeEach( () => {
+		const editorElement = document.createElement( 'div' );
+
+		addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );
+
+		document.body.appendChild( editorElement );
+		return ClassicTestEditor
+			.create( editorElement, {
+				plugins: [ SpecialCharacters, SpecialCharactersLatin ]
+			} )
+			.then( () => {
+				addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
+			} );
+	} );
+
+	afterEach( () => {
+		addItemsSpy.restore();
+	} );
+
+	it( 'adds new items', () => {
+		expect( addItemsSpy.callCount ).to.equal( 1 );
+	} );
+
+	it( 'properly names the category', () => {
+		expect( addItemsFirstCallArgs[ 0 ] ).to.be.equal( 'Latin' );
+	} );
+
+	it( 'adds proper characters', () => {
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: 'Ō',
+			title: 'Latin capital letter o with macron'
+		} );
+
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: 'Ō',
+			title: 'Latin capital letter o with macron'
+		} );
+	} );
+} );

+ 56 - 0
packages/ckeditor5-special-characters/tests/specialcharacterstext.js

@@ -0,0 +1,56 @@
+/**
+ * @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 document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import SpecialCharacters from '../src/specialcharacters';
+import SpecialCharactersText from '../src/specialcharacterstext';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'SpecialCharactersText', () => {
+	testUtils.createSinonSandbox();
+
+	let addItemsSpy, addItemsFirstCallArgs;
+
+	beforeEach( () => {
+		const editorElement = document.createElement( 'div' );
+
+		addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );
+
+		document.body.appendChild( editorElement );
+		return ClassicTestEditor
+			.create( editorElement, {
+				plugins: [ SpecialCharacters, SpecialCharactersText ]
+			} )
+			.then( () => {
+				addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
+			} );
+	} );
+
+	afterEach( () => {
+		addItemsSpy.restore();
+	} );
+
+	it( 'adds new items', () => {
+		expect( addItemsSpy.callCount ).to.equal( 1 );
+	} );
+
+	it( 'properly names the category', () => {
+		expect( addItemsFirstCallArgs[ 0 ] ).to.be.equal( 'Text' );
+	} );
+
+	it( 'adds proper characters', () => {
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: '…',
+			title: 'Horizontal ellipsis'
+		} );
+
+		expect( addItemsFirstCallArgs[ 1 ] ).to.deep.include( {
+			character: '“',
+			title: 'Left double quotation mark'
+		} );
+	} );
+} );