diff --git a/tests/integration/whisp/whisp.service.int-spec.ts b/tests/integration/whisp/whisp.service.int-spec.ts index 01ba8a067..9f5fc4fc6 100644 --- a/tests/integration/whisp/whisp.service.int-spec.ts +++ b/tests/integration/whisp/whisp.service.int-spec.ts @@ -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 () => { @@ -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', () => { @@ -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[] = [ + { + dataIndexKey: 'test', + }, + ]; + + const result = await whispService.countWhispsGroup(filter); + + expect(result[0].count.valueOf()).toEqual(3); + }); }); }); diff --git a/tests/unit/whisp/whisp.service.spec.ts b/tests/unit/whisp/whisp.service.spec.ts index 83bb12d3c..730f10886 100644 --- a/tests/unit/whisp/whisp.service.spec.ts +++ b/tests/unit/whisp/whisp.service.spec.ts @@ -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', () => {