AAE-30882 - Fixed unit test for js-api

This commit is contained in:
VitoAlbano
2025-08-22 12:48:30 +01:00
committed by Vito Albano
parent e400bc1068
commit c17c8232af
43 changed files with 575 additions and 460 deletions

View File

@@ -128,16 +128,15 @@ describe('Ecm Auth test', () => {
);
});
it('login should return an error if wrong credential are used 400 userId and/or password are/is not provided', (done) => {
it('login should return an error if wrong credential are used 400 userId and/or password are/is not provided', async () => {
authEcmMock.get400Response();
contentAuth.login(null, null).then(
() => {},
(error) => {
assert.equal(error.status, 400);
done();
}
);
try {
await contentAuth.login(null, null);
assert.fail('Login should have failed');
} catch (error) {
assert.equal(error.status, 400);
}
});
describe('Events ', () => {
@@ -189,8 +188,6 @@ describe('Ecm Auth test', () => {
describe('With Ticket Authentication', () => {
it('Ticket should be present in the client', () => {
authEcmMock.get400Response();
contentAuth = new ContentAuth(
{
ticketEcm: 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1',
@@ -212,24 +209,22 @@ describe('Ecm Auth test', () => {
});
});
it('Ticket should be absent in the client and the resolve promise should be called', (done) => {
it('Ticket should be absent in the client and the resolve promise should be called', async () => {
authEcmMock.get204ResponseLogout();
contentAuth.logout().then(() => {
assert.equal(contentAuth.config.ticket, undefined);
done();
});
await contentAuth.logout();
assert.equal(contentAuth.config.ticket, undefined);
});
it('Logout should be rejected if the Ticket is already expired', (done) => {
it('Logout should be rejected if the Ticket is already expired', async () => {
authEcmMock.get404ResponseLogout();
contentAuth.logout().then(
() => {},
(error) => {
assert.equal(error.error.toString(), 'Error: Not Found');
done();
}
);
try {
await contentAuth.logout();
assert.fail('Logout should have failed');
} catch (error) {
assert.equal(error.status, 404);
assert.equal(error.response.data.error.briefSummary, 'Not Found');
}
});
});
});