From f2b339a30cc3f0343e8bd366f5e33b4cc9f3b371 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 28 May 2021 14:02:15 +0200 Subject: [PATCH] Fix existing GCS tests to match others. Signed-off-by: Eric Peterson --- packages/techdocs-common/__mocks__/@google-cloud/storage.ts | 3 +++ .../techdocs-common/src/stages/publish/googleStorage.test.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/techdocs-common/__mocks__/@google-cloud/storage.ts b/packages/techdocs-common/__mocks__/@google-cloud/storage.ts index 5e9890cd98..684c4023d7 100644 --- a/packages/techdocs-common/__mocks__/@google-cloud/storage.ts +++ b/packages/techdocs-common/__mocks__/@google-cloud/storage.ts @@ -63,6 +63,9 @@ class GCSFile { process.nextTick(() => { if (fs.existsSync(this.localFilePath)) { + if (readable.eventNames().includes('pipe')) { + readable.emit('pipe'); + } readable.emit('data', fs.readFileSync(this.localFilePath)); readable.emit('end'); } else { diff --git a/packages/techdocs-common/src/stages/publish/googleStorage.test.ts b/packages/techdocs-common/src/stages/publish/googleStorage.test.ts index f29e1f10be..c4c032015e 100644 --- a/packages/techdocs-common/src/stages/publish/googleStorage.test.ts +++ b/packages/techdocs-common/src/stages/publish/googleStorage.test.ts @@ -309,7 +309,9 @@ describe('GoogleGCSPublish', () => { const pngResponse = await request(app).get( `/${namespace}/${kind}/${name}/img/with%20spaces.png`, ); - expect(pngResponse.text).toEqual('found it'); + expect(Buffer.from(pngResponse.body).toString('utf8')).toEqual( + 'found it', + ); const jsResponse = await request(app).get( `/${namespace}/${kind}/${name}/some%20folder/also%20with%20spaces.js`, );