Skip to content

Commit

Permalink
fix: test case when subscription email is not subscribed
Browse files Browse the repository at this point in the history
  • Loading branch information
lui7henrique committed Oct 16, 2024
1 parent f424533 commit a131917
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
pg:
image: bitnami/postgresql:13.16.0
ports:
- '5432:5432'
- "5432:5432"
environment:
- POSTGRES_USER=docker
- POSTGRES_PASSWORD=docker
Expand All @@ -13,21 +13,20 @@ services:
pg-test:
image: bitnami/postgresql:13.16.0
ports:
- '5433:5432'
- "5433:5432"
environment:
- POSTGRES_USER=docker
- POSTGRES_PASSWORD=docker
- POSTGRES_DB=event-booster-test

redis:
image: bitnami/redis:latest
ports:
- '6379:6379'
- "6379:6379"
environment:
- REDIS_PASSWORD=redis
- REDIS_PASSWORD=redis
volumes:
- redis-data:/data

volumes:
redis-data:

11 changes: 11 additions & 0 deletions src/app/functions/generate-referral.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { beforeAll, describe, expect, it } from 'vitest'
import { ReferralLinkAlreadyExists } from '../errors/referral-link-already-exists'
import { generateReferral } from './generate-referral'
import { faker } from '@faker-js/faker'
import { SubscriptionNotFound } from '../errors/subscription-not-found-error'

let host: InferSelectModel<typeof schema.hosts>
let event: InferSelectModel<typeof schema.events>
Expand Down Expand Up @@ -37,6 +38,16 @@ describe('generate referral', () => {
})
})

it('should not be able to generate referral when email is not subscribed', async () => {
const sut = await generateReferral({
email: '[email protected]',
eventId: event.id,
})

expect(isLeft(sut)).toBe(true)
expect(unwrapEither(sut)).toBeInstanceOf(SubscriptionNotFound)
})

it('should not be able to generate referral when its already exists', async () => {
await makeReferralLink({
eventId: event.id,
Expand Down

0 comments on commit a131917

Please sign in to comment.