8
0
Просмотр исходного кода

Tests: Properly use sinon sandbox in tests.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
add2bdbadb

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -22,11 +22,11 @@ import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import testUtils from '../../tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'ClassicTestEditor', () => {
 	let editorElement;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		editorElement = document.createElement( 'div' );
 		document.body.appendChild( editorElement );

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/createsinonsandbox.js

@@ -11,9 +11,9 @@ const obj = {
 const origMethod = obj.method;
 let spy;
 
-testUtils.createSinonSandbox();
-
 describe( 'testUtils.createSinonSandbox()', () => {
+	testUtils.createSinonSandbox();
+
 	it( 'creates a sandbox', () => {
 		expect( testUtils.sinon ).to.be.an( 'object' );
 		expect( testUtils.sinon ).to.have.property( 'spy' );

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/modeltesteditor.js

@@ -15,9 +15,9 @@ import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model
 
 import testUtils from '../../tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'ModelTestEditor', () => {
+	testUtils.createSinonSandbox();
+
 	describe( 'constructor()', () => {
 		it( 'creates an instance of editor', () => {
 			const editor = new ModelTestEditor( { foo: 1 } );

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/utils.js

@@ -6,9 +6,9 @@
 import testUtils from '../_utils/utils';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
-testUtils.createSinonSandbox();
-
 describe( 'utils', () => {
+	testUtils.createSinonSandbox();
+
 	describe( 'checkAssertions()', () => {
 		it( 'does not throw an error if at least one assertion passed', () => {
 			const assertionRed = testUtils.sinon.stub().callsFake( () => {

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -12,9 +12,9 @@ import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
 
 import testUtils from '../../tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'VirtualTestEditor', () => {
+	testUtils.createSinonSandbox();
+
 	describe( 'constructor()', () => {
 		it( 'creates an instance of editor', () => {
 			const editor = new VirtualTestEditor( { foo: 1 } );

+ 2 - 2
packages/ckeditor5-core/tests/editor/editorui.js

@@ -12,11 +12,11 @@ import View from '@ckeditor/ckeditor5-ui/src/view';
 
 import testUtils from '../_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'EditorUI', () => {
 	let editor, view, ui;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		editor = new Editor();
 		view = new View();

+ 35 - 35
packages/ckeditor5-core/tests/plugincollection.js

@@ -18,42 +18,42 @@ class TestError extends Error {}
 class ChildPlugin extends Plugin {}
 class GrandPlugin extends ChildPlugin {}
 
-testUtils.createSinonSandbox();
-
-before( () => {
-	PluginA = createPlugin( 'A' );
-	PluginB = createPlugin( 'B' );
-	PluginC = createPlugin( 'C' );
-	PluginD = createPlugin( 'D' );
-	PluginE = createPlugin( 'E' );
-	PluginF = createPlugin( 'F' );
-	PluginG = createPlugin( 'G', GrandPlugin );
-	PluginH = createPlugin( 'H' );
-	PluginI = createPlugin( 'I' );
-	PluginJ = createPlugin( 'J' );
-	PluginK = createPlugin( 'K' );
-	PluginX = class extends Plugin {
-		constructor( editor ) {
-			super( editor );
-
-			throw new TestError( 'Some error inside a plugin' );
-		}
-	};
-	PluginFoo = createPlugin( 'Foo' );
-	AnotherPluginFoo = createPlugin( 'Foo' );
-
-	PluginC.requires = [ PluginB ];
-	PluginD.requires = [ PluginA, PluginC ];
-	PluginF.requires = [ PluginE ];
-	PluginE.requires = [ PluginF ];
-	PluginH.requires = [ PluginI ];
-	PluginJ.requires = [ 'K' ];
-	PluginK.requires = [ PluginA ];
-
-	editor = new Editor();
-} );
-
 describe( 'PluginCollection', () => {
+	testUtils.createSinonSandbox();
+
+	before( () => {
+		PluginA = createPlugin( 'A' );
+		PluginB = createPlugin( 'B' );
+		PluginC = createPlugin( 'C' );
+		PluginD = createPlugin( 'D' );
+		PluginE = createPlugin( 'E' );
+		PluginF = createPlugin( 'F' );
+		PluginG = createPlugin( 'G', GrandPlugin );
+		PluginH = createPlugin( 'H' );
+		PluginI = createPlugin( 'I' );
+		PluginJ = createPlugin( 'J' );
+		PluginK = createPlugin( 'K' );
+		PluginX = class extends Plugin {
+			constructor( editor ) {
+				super( editor );
+
+				throw new TestError( 'Some error inside a plugin' );
+			}
+		};
+		PluginFoo = createPlugin( 'Foo' );
+		AnotherPluginFoo = createPlugin( 'Foo' );
+
+		PluginC.requires = [ PluginB ];
+		PluginD.requires = [ PluginA, PluginC ];
+		PluginF.requires = [ PluginE ];
+		PluginE.requires = [ PluginF ];
+		PluginH.requires = [ PluginI ];
+		PluginJ.requires = [ 'K' ];
+		PluginK.requires = [ PluginA ];
+
+		editor = new Editor();
+	} );
+
 	beforeEach( () => {
 		availablePlugins = [
 			PluginA,