[MIGRATION] - Fixing failing migrated tests

This commit is contained in:
VitoAlbano
2024-11-14 23:34:18 +00:00
committed by Vito Albano
parent 76fecf705a
commit 7c6e9ab831
6 changed files with 61 additions and 27 deletions

View File

@@ -52,46 +52,38 @@ describe('Auth', () => {
});
describe('login', () => {
it('should return the Ticket if all is ok', (done) => {
it('should return the Ticket if all is ok', async () => {
authResponseEcmMock.get201Response();
alfrescoJsApi.login('admin', 'admin').then((data: string) => {
assert.equal(data, 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
done();
});
const data = await alfrescoJsApi.login('admin', 'admin');
assert.equal(data, 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
});
it('should return an error if wrong credential are used 403 the login fails', (done) => {
it('should return an error if wrong credential are used 403 the login fails', async () => {
authResponseEcmMock.get403Response();
alfrescoJsApi.login('wrong', 'name').then(NOOP, (error: ErrorResponse) => {
assert.equal(error.status, 403);
done();
});
const error = await alfrescoJsApi.login('wrong', 'name');
assert.equal(error.status, 403);
});
});
describe('isLoggedIn', () => {
it('should return true if the api is logged in', (done) => {
it('should return true if the api is logged in', async () => {
authResponseEcmMock.get201Response();
alfrescoJsApi.login('admin', 'admin').then(() => {
assert.equal(alfrescoJsApi.isLoggedIn(), true);
done();
});
await alfrescoJsApi.login('admin', 'admin');
assert.equal(alfrescoJsApi.isLoggedIn(), true);
});
it('should return false if the api is logged out', (done) => {
it('should return false if the api is logged out', async () => {
authResponseEcmMock.get201Response();
alfrescoJsApi.login('admin', 'admin').catch(NOOP);
authResponseEcmMock.get204ResponseLogout();
alfrescoJsApi.logout().then(() => {
assert.equal(alfrescoJsApi.isLoggedIn(), false);
done();
});
await alfrescoJsApi.logout();
assert.equal(alfrescoJsApi.isLoggedIn(), false);
});
});

View File

@@ -55,7 +55,7 @@ describe('Bpm Auth test', () => {
});
describe('With Authentication', () => {
it('login should return the Ticket if all is ok', (done) => {
it('login should return the Ticket if all is ok', async () => {
authBpmMock.get200Response();
const processAuth = new ProcessAuth({
@@ -63,10 +63,8 @@ describe('Bpm Auth test', () => {
contextRootBpm: 'activiti-app'
});
processAuth.login('admin', 'admin').then((data) => {
assert.equal(data, 'Basic YWRtaW46YWRtaW4=');
done();
});
const data = await processAuth.login('admin', 'admin');
assert.equal(data, 'Basic YWRtaW46YWRtaW4=');
});
it('login password should be removed after login', (done) => {

View File

@@ -103,7 +103,7 @@ describe('Tags', () => {
});
describe('createTags', () => {
it('should return created tags', (done: Mocha.Done) => {
it('should return created tags', (done) => {
tagMock.createTags201Response();
tagsApi.createTags([new TagBody(), new TagBody()]).then((tags) => {
assert.equal(tags.length, 2);

View File

@@ -8,7 +8,7 @@
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"lib": ["ESNext", "dom"],
"types": ["mocha"]
"types": ["jest", "node"]
},
"exclude": [],
"include": ["**/*"]