Skip to content

Commit

Permalink
test(pods): add additional test w/o referral attached
Browse files Browse the repository at this point in the history
  • Loading branch information
mmackz committed Jul 16, 2024
1 parent 0278d6f commit 575cc9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion packages/pods/src/Pods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { describe, expect, test, vi } from 'vitest'
import { getExternalUrl, getMintIntent, mint } from './Pods'
import { failingTestCases, passingTestCases } from './test-setup'
import { EXPECTED_ENCODED_DATA_1155 } from './test-transactions'
import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses'

describe('Given the pods plugin', () => {
describe('When handling the mint', () => {
Expand Down Expand Up @@ -203,7 +204,7 @@ describe('simulateMint function', () => {
})

describe('getExternalUrl function', () => {
test('should return correct url for mint w/tokenId', async () => {
test('should return correct url for mint w/tokenId and referral', async () => {
const params = {
chainId: Chains.BASE,
contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'),
Expand All @@ -216,6 +217,18 @@ describe('getExternalUrl function', () => {
)
})

test('should return correct url for mint w/tokenId and w/o referral', async () => {
const params = {
chainId: Chains.BASE,
contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'),
tokenId: 21,
}
const result = await getExternalUrl(params)
expect(result).toBe(
`https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=${ZORA_DEPLOYER_ADDRESS}`,
)
})

test('should return correct url for mint w/out tokenId', async () => {
const params = {
chainId: Chains.BASE,
Expand Down
2 changes: 1 addition & 1 deletion packages/pods/src/Pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const getExternalUrl = async (
// different properties depending on uri function. One of these will be defined
const baseUrl = data.external_link ?? data.external_url

return referral ? `${baseUrl}?referrer=${referral}` : baseUrl
return `${baseUrl}?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}`
} catch (error) {
console.error('an error occurred fetching data from the contract')
if (error instanceof Error) {
Expand Down

0 comments on commit 575cc9d

Please sign in to comment.