Skip to content

Commit

Permalink
Merge pull request #842 from Sanofi-IADC/feature/WEB-2336
Browse files Browse the repository at this point in the history
fix: WEB-2336 added test cases for data index changes
  • Loading branch information
sairam459 authored Jun 26, 2024
2 parents f783fee + f8065cc commit c00048b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/integration/whisp/whisp.service.int-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ describe('WhispService', () => {

expect(result.timestamp.valueOf()).toEqual(timestamp.valueOf());
});
it('should create whisp data index key', async () => {
const result = await whispService.create({ dataIndexKey: 'test' });

expect(result.dataIndexKey.valueOf()).toEqual('test');
});
});
describe('Update Whisp', () => {
it('should update timestamp when it is provided', async () => {
Expand All @@ -87,6 +92,13 @@ describe('WhispService', () => {

expect(result.timestamp.valueOf()).toEqual(initialWhisp.timestamp.valueOf());
});

it('should update whisp data index key', async () => {
const initialWhisp = await whispService.create({ dataIndexKey: 'test' });
const result = await whispService.update(initialWhisp._id, { dataIndexKey: 'test2' });

expect(result.dataIndexKey.valueOf()).toEqual('test2');
});
});

describe('Update Whisp', () => {
Expand Down Expand Up @@ -200,5 +212,21 @@ describe('WhispService', () => {
expect(result.length).toBeGreaterThan(0);
expect(result[0].count.valueOf()).toEqual(6);
});

it('should count whisps based on data index key', async () => {
await whispService.create({ dataIndexKey: 'test' });
await whispService.create({ dataIndexKey: 'test' });
await whispService.create({ dataIndexKey: 'test' });

const filter: Record<string, unknown>[] = [
{
dataIndexKey: 'test',
},
];

const result = await whispService.countWhispsGroup(filter);

expect(result[0].count.valueOf()).toEqual(3);
});
});
});
7 changes: 7 additions & 0 deletions tests/unit/whisp/whisp.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ describe('WhispService', () => {
expect(expirationDate).toStrictEqual(expirationDateField);
expect(timeToLiveSec).toBeNull();
});

it('create whisp with data index key', async () => {
const dataIndexKey = 'test';
const whisp = await whispService.create({ dataIndexKey });

expect(whisp.dataIndexKey).toBe(dataIndexKey);
});
});

describe('Update Whisp', () => {
Expand Down

0 comments on commit c00048b

Please sign in to comment.