Skip to content

Commit

Permalink
EPMRPP-82648 || update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AliakseiLiasnitski committed Feb 19, 2024
1 parent 770fc25 commit 1ea1f75
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions spec/report-portal-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ describe('ReportPortal javascript client', () => {
});
});

describe('calculateNonRetriedItemMapKey', () => {
describe('calculateExecutableItemMapKey', () => {
it("should return correct parameter's string", () => {
const client = new RPClient({
apiKey: 'test',
project: 'test',
endpoint: 'https://abc.com',
});

const str = client.calculateNonRetriedItemMapKey('lId', 'pId', 'name', 'itemId');
const str = client.calculateExecutableItemMapKey('lId', 'pId', 'name', 'itemId');

expect(str).toEqual('lId__pId__name__itemId');
});
Expand All @@ -83,7 +83,7 @@ describe('ReportPortal javascript client', () => {
endpoint: 'https://abc.com',
});

const str = client.calculateNonRetriedItemMapKey('lId', 'pId', 'name');
const str = client.calculateExecutableItemMapKey('lId', 'pId', 'name');

expect(str).toEqual('lId__pId__name__');
});
Expand Down Expand Up @@ -725,17 +725,17 @@ describe('ReportPortal javascript client', () => {
promiseStart: Promise.resolve(),
},
};
spyOn(client.nonRetriedItemMap, 'get').and.resolveTo();
spyOn(client.executableItemMap, 'get').and.resolveTo();
spyOn(client.restClient, 'create').and.resolveTo({});
spyOn(client, 'getUniqId').and.returnValue('4n5pxq24kpiob12og9');

const result = client.startTestItem({ retry: true }, 'id1', 'id');
const result = client.startTestItem({ retry: false }, 'id1', 'id');

expect(result.tempId).toEqual('4n5pxq24kpiob12og9');
return expectAsync(result.promise).toBeResolved();
});

it('should call nonRetriedItemMap if retry is false', () => {
it('should get previous try promise from executableItemMap if retry is true', () => {
const client = new RPClient({
apiKey: 'startLaunchTest',
endpoint: 'https://rp.us/api/v1',
Expand All @@ -754,17 +754,14 @@ describe('ReportPortal javascript client', () => {
promiseStart: Promise.resolve(),
},
};
spyOn(client, 'calculateNonRetriedItemMapKey').and.returnValue('id1__name__');
spyOn(client, 'calculateExecutableItemMapKey').and.returnValue('id1__name__');
spyOn(client, 'getUniqId').and.returnValue('4n5pxq24kpiob12og9');
spyOn(client.map['4n5pxq24kpiob12og9'], 'promiseStart').and.resolveTo();
spyOn(client.nonRetriedItemMap, 'set');
spyOn(client.executableItemMap, 'get');

client.startTestItem({ retry: false }, 'id1');
client.startTestItem({ retry: true }, 'id1');

expect(client.nonRetriedItemMap.set).toHaveBeenCalledWith(
'id1__name__',
client.map['4n5pxq24kpiob12og9'].promiseStart,
);
expect(client.executableItemMap.get).toHaveBeenCalledWith('id1__name__');
});
});

Expand Down

0 comments on commit 1ea1f75

Please sign in to comment.