Parcourir la source

Merge branch 'master' into memory-test

Maciej Gołaszewski il y a 5 ans
Parent
commit
947e31dcc3
1 fichiers modifiés avec 31 ajouts et 0 suppressions
  1. 31 0
      packages/ckeditor5-cloud-services/tests/cloudservices.js

+ 31 - 0
packages/ckeditor5-cloud-services/tests/cloudservices.js

@@ -136,4 +136,35 @@ describe( 'CloudServices', () => {
 			} );
 		} );
 	} );
+
+	describe( 'destroy()', () => {
+		it( 'should destroy created token when tokenUrl was provided', async () => {
+			CloudServices.Token.initialToken = 'initial-token';
+
+			const context = await Context.create( {
+				plugins: [ CloudServices ],
+				cloudServices: {
+					tokenUrl: 'http://token-endpoint'
+				}
+			} );
+
+			const cloudServicesPlugin = context.plugins.get( CloudServices );
+
+			const destroySpy = sinon.spy( cloudServicesPlugin.token, 'destroy' );
+
+			await context.destroy();
+
+			sinon.assert.calledOnce( destroySpy );
+		} );
+
+		it( 'should not crash when tokenUrl was not provided', async () => {
+			const context = await Context.create( { plugins: [ CloudServices ] } );
+
+			try {
+				await context.destroy();
+			} catch ( error ) {
+				expect.fail( 'Error should not be thrown.' );
+			}
+		} );
+	} );
 } );