Skip to content

Commit

Permalink
[MIGRATION] - Migrating to Jest - working but some tests fails
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoAlbano authored and ehsan-2019 committed Nov 28, 2024
1 parent 5d37c7d commit 78c8888
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
13 changes: 7 additions & 6 deletions lib/js-api/test/oauth2Auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -464,7 +465,7 @@ describe('Oauth2 test', () => {
});

alfrescoApi.login('admin', 'admin');
this.timeout(3000);
jest.setTimeout(3000);
alfrescoApi.refreshToken();
});

Expand Down
10 changes: 4 additions & 6 deletions lib/js-api/test/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 78c8888

Please sign in to comment.