From f19982cda76b590d2c00daab408d6901d009d6a2 Mon Sep 17 00:00:00 2001 From: Todd Evanoff Date: Thu, 26 Oct 2023 12:55:43 -0700 Subject: [PATCH] fix test --- src/write-archive/index.test.ts | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/write-archive/index.test.ts b/src/write-archive/index.test.ts index 523a2c38..e162d614 100644 --- a/src/write-archive/index.test.ts +++ b/src/write-archive/index.test.ts @@ -23,8 +23,7 @@ describe('writeTestResult', () => { diffThreshold: 5, pauseAnimationAtEnd: true, viewports: [720], - }, - new Map() + } ); expect(fs.ensureDir).toHaveBeenCalledTimes(1); expect(fs.outputFile).toHaveBeenCalledTimes(2); @@ -53,7 +52,12 @@ describe('writeTestResult', () => { childNodes: [ { attributes: { - src: '/bogano', + src: '/home/', + }, + }, + { + attributes: { + src: '/img?src=some-path', }, }, ], @@ -63,15 +67,17 @@ describe('writeTestResult', () => { childNodes: [ { attributes: { - src: '/coruscant', + src: '/home/index.html', + }, + }, + { + attributes: { + src: '/img-fe2b41833610050d950fb9112407d3b3.png', }, }, ], }; - const sourceMapping = new Map(); - sourceMapping.set('/bogano', '/coruscant'); - const expectedBuffer = Buffer.from(JSON.stringify(expectedMappedJson)); await writeTestResult( @@ -79,18 +85,22 @@ describe('writeTestResult', () => { { title: 'Toy Story', outputDir: resolve('test-results/toy-story-chromium') } as TestInfo, { home: Buffer.from(JSON.stringify(storyJson)) }, { - 'http://localhost:3000/home': { + 'http://localhost:3000/home/': { statusCode: 200, body: Buffer.from(JSON.stringify(storyJson)), }, + 'http://localhost:3000/img?src=some-path': { + statusCode: 200, + body: Buffer.from(JSON.stringify(storyJson)), + contentType: 'image/png', + }, }, - { viewports: [720] }, - sourceMapping + { viewports: [720] } ); expect(fs.ensureDir).toHaveBeenCalledTimes(1); expect(fs.outputJson).toHaveBeenCalledTimes(1); - expect(fs.outputFile).toHaveBeenCalledTimes(2); + expect(fs.outputFile).toHaveBeenCalledTimes(3); expect(fs.outputFile).toHaveBeenCalledWith( resolve('./test-results/chromatic-archives/archive/toy-story-home.snapshot.json'), expectedBuffer @@ -123,8 +133,7 @@ describe('writeTestResult', () => { } as TestInfo, { home: Buffer.from('Chromatic') }, { 'http://localhost:3000/home': { statusCode: 200, body: Buffer.from('Chromatic') } }, - { viewports: [720] }, - new Map() + { viewports: [720] } ); expect(fs.ensureDir).toHaveBeenCalledTimes(1); expect(fs.outputFile).toHaveBeenCalledTimes(2);