From b251c1d2caaf2a0cb70cbefc15f6998806b0a791 Mon Sep 17 00:00:00 2001 From: SoulKa Date: Thu, 31 Oct 2024 08:53:22 +0100 Subject: [PATCH] #108 - add test to loadTextBodyOfRequest with encoding --- .../service/persistence-service.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/persistence/service/persistence-service.test.ts b/src/main/persistence/service/persistence-service.test.ts index 2d72a5ba..32bbea80 100644 --- a/src/main/persistence/service/persistence-service.test.ts +++ b/src/main/persistence/service/persistence-service.test.ts @@ -342,6 +342,24 @@ describe('PersistenceService', () => { expect(await streamToString(result)).toBe(textBody); }); + it('loadTextBodyOfRequest() should load the text body of a request with utf8', async () => { + // Arrange + const textBody = 'text body'; + const request = getExampleRequest(collection.id); + collection.children.push(request); + + await persistenceService.saveCollectionRecursive(collection); + await persistenceService.saveRequest(request, textBody); + + // Act + const result = ( + await Array.fromAsync(await persistenceService.loadTextBodyOfRequest(request, 'utf8')) + ).join(''); + + // Assert + expect(result).toBe(textBody); + }); + it('loadTextBodyOfRequest() should load the text body of a draft request', async () => { // Arrange const textBody = 'text body';