diff --git a/functions/api/image/nfts/collection/collectionImage.test.ts b/functions/api/image/nfts/collection/collectionImage.test.ts index 95f3a8b225..f5b67dbd13 100644 --- a/functions/api/image/nfts/collection/collectionImage.test.ts +++ b/functions/api/image/nfts/collection/collectionImage.test.ts @@ -7,19 +7,19 @@ const collectionImageUrls = [ 'http://127.0.0.1:3000/api/image/nfts/collection/0x49cf6f5d44e70224e2e23fdcdd2c053f30ada28b', ] -const nonexistentImageUrls = [ - 'http://127.0.0.1:3000/api/image/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c545', -] - -test.each([...collectionImageUrls, ...nonexistentImageUrls])('collectionImageUrl', async (url) => { +test.each([...collectionImageUrls])('collectionImageUrl', async (url) => { const response = await fetch(new Request(url)) expect(response.status).toBe(200) expect(response.headers.get('content-type')).toBe('image/png') }) +const nonexistentImageUrls = [ + 'http://127.0.0.1:3000/api/image/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c545', +] + const invalidCollectionImageUrls = ['http://127.0.0.1:3000/api/image/nfts/collection/0xd3adb33f'] -test.each(invalidCollectionImageUrls)('invalidAssetImageUrl', async (url) => { +test.each([...invalidCollectionImageUrls, ...nonexistentImageUrls])('invalidAssetImageUrl', async (url) => { const response = await fetch(new Request(url)) expect(response.status).toBeOneOf([404, 500]) }) diff --git a/functions/nfts/collection/__snapshots__/collection.test.ts.snap b/functions/nfts/collection/__snapshots__/collection.test.ts.snap index 34c951d52e..d0c026d8e7 100644 --- a/functions/nfts/collection/__snapshots__/collection.test.ts.snap +++ b/functions/nfts/collection/__snapshots__/collection.test.ts.snap @@ -443,151 +443,3 @@ exports[`should inject metadata for collections 3`] = ` " `; - -exports[`should inject metadata for collections 4`] = ` -" - - - - - Uniswap Interface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
- - -" -`; diff --git a/functions/nfts/collection/collection.test.ts b/functions/nfts/collection/collection.test.ts index 165a6d611b..72132887b7 100644 --- a/functions/nfts/collection/collection.test.ts +++ b/functions/nfts/collection/collection.test.ts @@ -16,15 +16,7 @@ const collections = [ }, ] -const nonexistentCollections = [ - { - address: '0xed5af388653567af2f388e6224dc7c4b3241c545', - collectionName: '0xed5af388653567af2f388e6224dc7c4b3241c545', - image: 'http://127.0.0.1:3000/api/image/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c545', - }, -] - -test.each([...collections, ...nonexistentCollections])('should inject metadata for collections', async (collection) => { +test.each([...collections])('should inject metadata for collections', async (collection) => { const url = 'http://127.0.0.1:3000/nfts/collection/' + collection.address const body = await fetch(new Request(url)).then((res) => res.text()) expect(body).toMatchSnapshot() @@ -42,24 +34,33 @@ test.each([...collections, ...nonexistentCollections])('should inject metadata f expect(body).toContain(``) }) +const nonexistentCollections = [ + { + address: '0xed5af388653567af2f388e6224dc7c4b3241c545', + }, +] + const invalidCollections = [ { address: '0xd3adb33f', }, ] -test.each(invalidCollections)('should not inject metadata for nonexistent collections', async (collection) => { - const url = 'http://127.0.0.1:3000/nfts/collection/' + collection.address - const body = await fetch(new Request(url)).then((res) => res.text()) - expect(body).not.toContain('og:title') - expect(body).not.toContain('og:image') - expect(body).not.toContain('og:image:width') - expect(body).not.toContain('og:image:height') - expect(body).not.toContain('og:type') - expect(body).not.toContain('og:url') - expect(body).not.toContain('og:image:alt') - expect(body).not.toContain('twitter:card') - expect(body).not.toContain('twitter:title') - expect(body).not.toContain('twitter:image') - expect(body).not.toContain('twitter:image:alt') -}) +test.each([...invalidCollections, ...nonexistentCollections])( + 'should not inject metadata for nonexistent collections', + async (collection) => { + const url = 'http://127.0.0.1:3000/nfts/collection/' + collection.address + const body = await fetch(new Request(url)).then((res) => res.text()) + expect(body).not.toContain('og:title') + expect(body).not.toContain('og:image') + expect(body).not.toContain('og:image:width') + expect(body).not.toContain('og:image:height') + expect(body).not.toContain('og:type') + expect(body).not.toContain('og:url') + expect(body).not.toContain('og:image:alt') + expect(body).not.toContain('twitter:card') + expect(body).not.toContain('twitter:title') + expect(body).not.toContain('twitter:image') + expect(body).not.toContain('twitter:image:alt') + } +)