Преглед изворни кода

Tests: Improved assertions in the BlockToolbar tests.

Aleksander Nowodzinski пре 7 година
родитељ
комит
369d30d075

+ 28 - 28
packages/ckeditor5-ui/tests/toolbar/block/blocktoolbar.js

@@ -70,11 +70,11 @@ describe( 'BlockToolbar', () => {
 			} );
 			} );
 
 
 			it( 'should add panelView to ui.focusTracker', () => {
 			it( 'should add panelView to ui.focusTracker', () => {
-				expect( editor.ui.focusTracker.isFocused ).to.false;
+				expect( editor.ui.focusTracker.isFocused ).to.be.false;
 
 
 				blockToolbar.panelView.element.dispatchEvent( new Event( 'focus' ) );
 				blockToolbar.panelView.element.dispatchEvent( new Event( 'focus' ) );
 
 
-				expect( editor.ui.focusTracker.isFocused ).to.true;
+				expect( editor.ui.focusTracker.isFocused ).to.be.true;
 			} );
 			} );
 
 
 			it( 'should close panelView after `Esc` press and focus view document', () => {
 			it( 'should close panelView after `Esc` press and focus view document', () => {
@@ -88,7 +88,7 @@ describe( 'BlockToolbar', () => {
 					stopPropagation: () => {}
 					stopPropagation: () => {}
 				} );
 				} );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.false;
+				expect( blockToolbar.panelView.isVisible ).to.be.false;
 				sinon.assert.calledOnce( spy );
 				sinon.assert.calledOnce( spy );
 			} );
 			} );
 
 
@@ -99,7 +99,7 @@ describe( 'BlockToolbar', () => {
 				blockToolbar.panelView.isVisible = true;
 				blockToolbar.panelView.isVisible = true;
 				document.body.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
 				document.body.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.false;
+				expect( blockToolbar.panelView.isVisible ).to.be.false;
 				sinon.assert.notCalled( spy );
 				sinon.assert.notCalled( spy );
 			} );
 			} );
 
 
@@ -107,7 +107,7 @@ describe( 'BlockToolbar', () => {
 				blockToolbar.panelView.isVisible = true;
 				blockToolbar.panelView.isVisible = true;
 				blockToolbar.panelView.element.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
 				blockToolbar.panelView.element.dispatchEvent( new Event( 'mousedown', { bubbles: true } ) );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.true;
+				expect( blockToolbar.panelView.isVisible ).to.be.true;
 			} );
 			} );
 		} );
 		} );
 
 
@@ -117,7 +117,7 @@ describe( 'BlockToolbar', () => {
 			} );
 			} );
 
 
 			it( 'should add additional class to toolbar element', () => {
 			it( 'should add additional class to toolbar element', () => {
-				expect( blockToolbar.toolbarView.element.classList.contains( 'ck-toolbar_floating' ) ).to.true;
+				expect( blockToolbar.toolbarView.element.classList.contains( 'ck-toolbar_floating' ) ).to.be.true;
 			} );
 			} );
 
 
 			it( 'should be added to panelView#content collection', () => {
 			it( 'should be added to panelView#content collection', () => {
@@ -131,11 +131,11 @@ describe( 'BlockToolbar', () => {
 			it( 'should hide panel after clicking on the button from toolbar', () => {
 			it( 'should hide panel after clicking on the button from toolbar', () => {
 				blockToolbar.buttonView.fire( 'execute' );
 				blockToolbar.buttonView.fire( 'execute' );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.true;
+				expect( blockToolbar.panelView.isVisible ).to.be.true;
 
 
 				blockToolbar.toolbarView.items.get( 0 ).fire( 'execute' );
 				blockToolbar.toolbarView.items.get( 0 ).fire( 'execute' );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.false;
+				expect( blockToolbar.panelView.isVisible ).to.be.false;
 			} );
 			} );
 		} );
 		} );
 
 
@@ -149,22 +149,22 @@ describe( 'BlockToolbar', () => {
 			} );
 			} );
 
 
 			it( 'should add buttonView to ui.focusTracker', () => {
 			it( 'should add buttonView to ui.focusTracker', () => {
-				expect( editor.ui.focusTracker.isFocused ).to.false;
+				expect( editor.ui.focusTracker.isFocused ).to.be.false;
 
 
 				blockToolbar.buttonView.element.dispatchEvent( new Event( 'focus' ) );
 				blockToolbar.buttonView.element.dispatchEvent( new Event( 'focus' ) );
 
 
-				expect( editor.ui.focusTracker.isFocused ).to.true;
+				expect( editor.ui.focusTracker.isFocused ).to.be.true;
 			} );
 			} );
 
 
 			it( 'should pin panelView to the button and focus first item in toolbar on #execute event', () => {
 			it( 'should pin panelView to the button and focus first item in toolbar on #execute event', () => {
-				expect( blockToolbar.panelView.isVisible ).to.false;
+				expect( blockToolbar.panelView.isVisible ).to.be.false;
 
 
 				const pinSpy = testUtils.sinon.spy( blockToolbar.panelView, 'pin' );
 				const pinSpy = testUtils.sinon.spy( blockToolbar.panelView, 'pin' );
 				const focusSpy = testUtils.sinon.spy( blockToolbar.toolbarView.items.get( 0 ), 'focus' );
 				const focusSpy = testUtils.sinon.spy( blockToolbar.toolbarView.items.get( 0 ), 'focus' );
 
 
 				blockToolbar.buttonView.fire( 'execute' );
 				blockToolbar.buttonView.fire( 'execute' );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.true;
+				expect( blockToolbar.panelView.isVisible ).to.be.true;
 				sinon.assert.calledWith( pinSpy, {
 				sinon.assert.calledWith( pinSpy, {
 					target: blockToolbar.buttonView.element,
 					target: blockToolbar.buttonView.element,
 					limiter: editor.ui.view.editableElement
 					limiter: editor.ui.view.editableElement
@@ -178,28 +178,28 @@ describe( 'BlockToolbar', () => {
 
 
 				blockToolbar.buttonView.fire( 'execute' );
 				blockToolbar.buttonView.fire( 'execute' );
 
 
-				expect( blockToolbar.panelView.isVisible ).to.false;
+				expect( blockToolbar.panelView.isVisible ).to.be.false;
 				sinon.assert.calledOnce( spy );
 				sinon.assert.calledOnce( spy );
 			} );
 			} );
 
 
 			it( 'should bind #isOn to panelView#isVisible', () => {
 			it( 'should bind #isOn to panelView#isVisible', () => {
 				blockToolbar.panelView.isVisible = false;
 				blockToolbar.panelView.isVisible = false;
 
 
-				expect( blockToolbar.buttonView.isOn ).to.false;
+				expect( blockToolbar.buttonView.isOn ).to.be.false;
 
 
 				blockToolbar.panelView.isVisible = true;
 				blockToolbar.panelView.isVisible = true;
 
 
-				expect( blockToolbar.buttonView.isOn ).to.true;
+				expect( blockToolbar.buttonView.isOn ).to.be.true;
 			} );
 			} );
 
 
 			it( 'should hide button tooltip when panelView is opened', () => {
 			it( 'should hide button tooltip when panelView is opened', () => {
 				blockToolbar.panelView.isVisible = false;
 				blockToolbar.panelView.isVisible = false;
 
 
-				expect( blockToolbar.buttonView.tooltip ).to.true;
+				expect( blockToolbar.buttonView.tooltip ).to.be.true;
 
 
 				blockToolbar.panelView.isVisible = true;
 				blockToolbar.panelView.isVisible = true;
 
 
-				expect( blockToolbar.buttonView.tooltip ).to.false;
+				expect( blockToolbar.buttonView.tooltip ).to.be.false;
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );
@@ -211,25 +211,25 @@ describe( 'BlockToolbar', () => {
 
 
 			setData( editor.model, '<foo>foo[]bar</foo>' );
 			setData( editor.model, '<foo>foo[]bar</foo>' );
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.true;
+			expect( blockToolbar.buttonView.isVisible ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should display button when the first selected block is an object', () => {
 		it( 'should display button when the first selected block is an object', () => {
 			setData( editor.model, '[<image src="foo.jpg"><caption>foo</caption></image>]' );
 			setData( editor.model, '[<image src="foo.jpg"><caption>foo</caption></image>]' );
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.true;
+			expect( blockToolbar.buttonView.isVisible ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should display button when the selection is inside the object', () => {
 		it( 'should display button when the selection is inside the object', () => {
 			setData( editor.model, '<image src="foo.jpg"><caption>f[]oo</caption></image>' );
 			setData( editor.model, '<image src="foo.jpg"><caption>f[]oo</caption></image>' );
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.true;
+			expect( blockToolbar.buttonView.isVisible ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should not display button when the selection is placed in a root element', () => {
 		it( 'should not display button when the selection is placed in a root element', () => {
 			setData( editor.model, '<paragraph>foo</paragraph>[]<paragraph>bar</paragraph>' );
 			setData( editor.model, '<paragraph>foo</paragraph>[]<paragraph>bar</paragraph>' );
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.false;
+			expect( blockToolbar.buttonView.isVisible ).to.be.false;
 		} );
 		} );
 
 
 		it( 'should not display button when all toolbar items are disabled for the selected element', () => {
 		it( 'should not display button when all toolbar items are disabled for the selected element', () => {
@@ -245,7 +245,7 @@ describe( 'BlockToolbar', () => {
 
 
 				setData( editor.model, '[<image src="foo.jpg"></image>]' );
 				setData( editor.model, '[<image src="foo.jpg"></image>]' );
 
 
-				expect( blockToolbar.buttonView.isVisible ).to.false;
+				expect( blockToolbar.buttonView.isVisible ).to.be.false;
 
 
 				element.remove();
 				element.remove();
 
 
@@ -358,7 +358,7 @@ describe( 'BlockToolbar', () => {
 
 
 			editor.model.document.selection.fire( 'change:range', { directChange: true } );
 			editor.model.document.selection.fire( 'change:range', { directChange: true } );
 
 
-			expect( blockToolbar.panelView.isVisible ).to.false;
+			expect( blockToolbar.panelView.isVisible ).to.be.false;
 		} );
 		} );
 
 
 		it( 'should not hide opened panel on a selection not direct change', () => {
 		it( 'should not hide opened panel on a selection not direct change', () => {
@@ -366,7 +366,7 @@ describe( 'BlockToolbar', () => {
 
 
 			editor.model.document.selection.fire( 'change:range', { directChange: false } );
 			editor.model.document.selection.fire( 'change:range', { directChange: false } );
 
 
-			expect( blockToolbar.panelView.isVisible ).to.true;
+			expect( blockToolbar.panelView.isVisible ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should hide UI when editor switch to readonly when panel is not visible', () => {
 		it( 'should hide UI when editor switch to readonly when panel is not visible', () => {
@@ -377,8 +377,8 @@ describe( 'BlockToolbar', () => {
 
 
 			editor.isReadOnly = true;
 			editor.isReadOnly = true;
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.false;
-			expect( blockToolbar.panelView.isVisible ).to.false;
+			expect( blockToolbar.buttonView.isVisible ).to.be.false;
+			expect( blockToolbar.panelView.isVisible ).to.be.false;
 		} );
 		} );
 
 
 		it( 'should not hide button when editor switch to readonly when panel is visible', () => {
 		it( 'should not hide button when editor switch to readonly when panel is visible', () => {
@@ -389,8 +389,8 @@ describe( 'BlockToolbar', () => {
 
 
 			editor.isReadOnly = true;
 			editor.isReadOnly = true;
 
 
-			expect( blockToolbar.buttonView.isVisible ).to.true;
-			expect( blockToolbar.panelView.isVisible ).to.true;
+			expect( blockToolbar.buttonView.isVisible ).to.be.true;
+			expect( blockToolbar.panelView.isVisible ).to.be.true;
 		} );
 		} );
 
 
 		it( 'should update button position on browser resize only when button is visible', () => {
 		it( 'should update button position on browser resize only when button is visible', () => {

+ 2 - 2
packages/ckeditor5-ui/tests/toolbar/block/view/blockbuttonview.js

@@ -14,11 +14,11 @@ describe( 'BlockButtonView', () => {
 	} );
 	} );
 
 
 	it( 'should be not visible on init', () => {
 	it( 'should be not visible on init', () => {
-		expect( view.isVisible ).to.false;
+		expect( view.isVisible ).to.be.false;
 	} );
 	} );
 
 
 	it( 'should create element from template', () => {
 	it( 'should create element from template', () => {
-		expect( view.element.classList.contains( 'ck-block-toolbar-button' ) ).to.true;
+		expect( view.element.classList.contains( 'ck-block-toolbar-button' ) ).to.be.true;
 	} );
 	} );
 
 
 	describe( 'DOM binding', () => {
 	describe( 'DOM binding', () => {