Browse Source

Merge branch t/ckeditor5/1144

Tests: Properly use sinon sandbox in tests t/ckeditor5/1144.
Oskar Wróbel 7 năm trước cách đây
mục cha
commit
c32c36eeb4

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

@@ -8,11 +8,11 @@ import utilsTestUtils from '../../tests/_utils/utils';
 import ObesrvableMixin from '../../src/observablemixin';
 import EmitterMixin from '../../src/emittermixin';
 
-testUtils.createSinonSandbox();
-
 describe( 'utilsTestUtils.createObserver()', () => {
 	let observable, observable2, observer;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		observer = utilsTestUtils.createObserver();
 

+ 2 - 2
packages/ckeditor5-utils/tests/collection.js

@@ -7,8 +7,6 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import Collection from '../src/collection';
 import CKEditorError from '../src/ckeditorerror';
 
-testUtils.createSinonSandbox();
-
 function getItem( id, idProperty ) {
 	idProperty = idProperty || 'id';
 
@@ -20,6 +18,8 @@ function getItem( id, idProperty ) {
 describe( 'Collection', () => {
 	let collection;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		collection = new Collection();
 	} );

+ 2 - 2
packages/ckeditor5-utils/tests/dom/emittermixin.js

@@ -9,11 +9,11 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import DomEmitterMixin from '../../src/dom/emittermixin';
 import EmitterMixin from '../../src/emittermixin';
 
-testUtils.createSinonSandbox();
-
 describe( 'DomEmitterMixin', () => {
 	let emitter, domEmitter, node;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		emitter = Object.create( EmitterMixin );
 		domEmitter = Object.create( DomEmitterMixin );

+ 2 - 2
packages/ckeditor5-utils/tests/dom/getborderwidths.js

@@ -6,9 +6,9 @@
 import getBorderWidths from '../../src/dom/getborderwidths';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'getBorderWidths()', () => {
+	testUtils.createSinonSandbox();
+
 	it( 'returns CSS border widths', () => {
 		const elementMock = {
 			ownerDocument: {

+ 2 - 2
packages/ckeditor5-utils/tests/dom/global.js

@@ -8,9 +8,9 @@
 import global from '../../src/dom/global';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'global', () => {
+	testUtils.createSinonSandbox();
+
 	describe( 'global', () => {
 		describe( 'window', () => {
 			it( 'equals native DOM window', () => {

+ 2 - 2
packages/ckeditor5-utils/tests/dom/position.js

@@ -9,8 +9,6 @@ import { getOptimalPosition } from '../../src/dom/position';
 import Rect from '../../src/dom/rect';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 let element, target, limiter;
 
 //	+--------+-----+
@@ -54,6 +52,8 @@ const attachTop = ( targetRect, elementRect ) => ( {
 } );
 
 describe( 'getOptimalPosition()', () => {
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		testUtils.sinon.stub( window, 'getComputedStyle' );
 

+ 2 - 2
packages/ckeditor5-utils/tests/dom/rect.js

@@ -9,11 +9,11 @@ import Rect from '../../src/dom/rect';
 import log from '../../src/log';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'Rect', () => {
 	let geometry;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		geometry = {
 			top: 10,

+ 4 - 2
packages/ckeditor5-utils/tests/dom/scroll.js

@@ -9,11 +9,11 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import isRange from '../../src/dom/isrange';
 import { scrollViewportToShowTarget, scrollAncestorsToShowTarget } from '../../src/dom/scroll';
 
-testUtils.createSinonSandbox();
-
 describe( 'scrollAncestorsToShowTarget()', () => {
 	let target, element, firstAncestor, secondAncestor;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		element = document.createElement( 'p' );
 		firstAncestor = document.createElement( 'blockquote' );
@@ -145,6 +145,8 @@ describe( 'scrollViewportToShowTarget()', () => {
 	let target, firstAncestor, element;
 	const viewportOffset = 30;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		element = document.createElement( 'p' );
 		firstAncestor = document.createElement( 'blockquote' );

+ 2 - 2
packages/ckeditor5-utils/tests/focustracker.js

@@ -9,11 +9,11 @@ import FocusTracker from '../src/focustracker';
 import CKEditorError from '../src/ckeditorerror';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
-testUtils.createSinonSandbox();
-
 describe( 'FocusTracker', () => {
 	let focusTracker, container, containerFirstInput, containerSecondInput;
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( () => {
 		container = document.createElement( 'div' );
 		containerFirstInput = document.createElement( 'input' );

+ 4 - 2
packages/ckeditor5-utils/tests/observablemixin.js

@@ -13,9 +13,9 @@ import mix from '../src/mix';
 
 const assertBinding = utilsTestUtils.assertBinding;
 
-testUtils.createSinonSandbox();
-
 describe( 'ObservableMixin', () => {
+	testUtils.createSinonSandbox();
+
 	it( 'exists', () => {
 		expect( ObservableMixin ).to.be.an( 'object' );
 	} );
@@ -30,6 +30,8 @@ describe( 'ObservableMixin', () => {
 } );
 
 describe( 'Observable', () => {
+	testUtils.createSinonSandbox();
+
 	class Observable {
 		constructor( properties ) {
 			if ( properties ) {