From 3039d1612fbf5822cbf1aa16c68c709b648d6519 Mon Sep 17 00:00:00 2001 From: VitoAlbano Date: Fri, 15 Nov 2024 09:24:34 +0000 Subject: [PATCH] [MIGRATION] - Migrating to Jest - working but some tests fails --- lib/js-api/test/oauth2Auth.spec.ts | 13 +++++++------ lib/js-api/test/upload.spec.ts | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/js-api/test/oauth2Auth.spec.ts b/lib/js-api/test/oauth2Auth.spec.ts index 315ec84d20..741b8baa86 100644 --- a/lib/js-api/test/oauth2Auth.spec.ts +++ b/lib/js-api/test/oauth2Auth.spec.ts @@ -19,6 +19,7 @@ import assert from 'assert'; import { AlfrescoApi, ContentApi, Oauth2Auth } from '../src'; import { EcmAuthMock, OAuthMock } from './mockObjects'; import jsdom from 'jsdom'; +import { jest } from '@jest/globals'; const { JSDOM } = jsdom; const globalAny: any = global; @@ -168,8 +169,8 @@ describe('Oauth2 test', () => { }); }); - it('should refresh token when the login not use the implicitFlow ', function (done) { - this.timeout(3000); + it('should refresh token when the login not use the implicitFlow ', (done) => { + jest.setTimeout(3000); oauth2Mock.get200Response(); const oauth2Auth = new Oauth2Auth( @@ -204,8 +205,8 @@ describe('Oauth2 test', () => { oauth2Auth.login('admin', 'admin'); }); - it('should not hang the app also if teh logout is missing', function (done) { - this.timeout(3000); + it('should not hang the app also if teh logout is missing', (done) => { + jest.setTimeout(3000); oauth2Mock.get200Response(); const oauth2Auth = new Oauth2Auth( @@ -426,7 +427,7 @@ describe('Oauth2 test', () => { // TODO: very flaky test, fails on different machines if running slow, might relate to `this.timeout` // eslint-disable-next-line ban/ban xit('should extend content session after oauth token refresh', function (done) { - this.timeout(3000); + jest.setTimeout(3000); oauth2Mock.get200Response(); authResponseMock.get200ValidTicket(); @@ -464,7 +465,7 @@ describe('Oauth2 test', () => { }); alfrescoApi.login('admin', 'admin'); - this.timeout(3000); + jest.setTimeout(3000); alfrescoApi.refreshToken(); }); diff --git a/lib/js-api/test/upload.spec.ts b/lib/js-api/test/upload.spec.ts index a07ec97401..a4ee129780 100644 --- a/lib/js-api/test/upload.spec.ts +++ b/lib/js-api/test/upload.spec.ts @@ -61,12 +61,10 @@ describe('Upload', () => { const file = createTestFileStream('testFile.txt'); - uploadApi.uploadFile(file).catch( - (error: any) => { - assert.equal(error.status, 409); - done(); - } - ); + uploadApi.uploadFile(file).catch((error: any) => { + assert.equal(error.status, 409); + done(); + }); }); it('upload file should get 200 and rename if the new name clashes with an existing file in the current parent folder and autorename is true', async () => {