Skip to content

Commit

Permalink
clean up usages of accountDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry committed Dec 19, 2024
1 parent f065b32 commit 91efa0a
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/shared/utils/upgradeForm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ describe('calculatePriceTeamPlan', () => {
})

describe('getDefaultValuesUpgradeForm', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>
const proPlanYear = { value: Plans.USERS_PR_INAPPY } as Plan
const sentryPlanYear = { value: Plans.USERS_SENTRYY } as Plan
const teamPlanMonth = { value: Plans.USERS_TEAMM } as Plan

describe('when current plan is basic', () => {
it('returns pro year plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

const data = getDefaultValuesUpgradeForm({
accountDetails,
selectedPlan: proPlanYear,
Expand All @@ -128,8 +127,6 @@ describe('getDefaultValuesUpgradeForm', () => {
})

it('returns sentry year plan if user is sentry upgrade', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

const data = getDefaultValuesUpgradeForm({
accountDetails,
selectedPlan: proPlanYear,
Expand All @@ -150,8 +147,6 @@ describe('getDefaultValuesUpgradeForm', () => {

describe('when current plan is team monthly', () => {
it('returns team monthly plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

const data = getDefaultValuesUpgradeForm({
accountDetails,
selectedPlan: proPlanYear,
Expand All @@ -170,8 +165,6 @@ describe('getDefaultValuesUpgradeForm', () => {
})

it('returns pro sentry plan if user is sentry upgrade', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

const data = getDefaultValuesUpgradeForm({
accountDetails,
selectedPlan: proPlanYear,
Expand All @@ -195,8 +188,6 @@ describe('getDefaultValuesUpgradeForm', () => {
})

it('returns current plan if the user is on a paid plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

const data = getDefaultValuesUpgradeForm({
accountDetails,
selectedPlan: proPlanYear,
Expand All @@ -220,10 +211,11 @@ describe('getDefaultValuesUpgradeForm', () => {
})

describe('getSchema', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>

it('passes parsing when all conditions are met', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({ accountDetails, minSeats: 5 })

const response = schema.safeParse({
Expand All @@ -235,9 +227,6 @@ describe('getSchema', () => {
})

it('fails to parse when newPlan is not a string', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({ accountDetails, minSeats: 5 })

const response = schema.safeParse({ seats: 5, newPlan: { value: 5 } })
Expand All @@ -252,9 +241,6 @@ describe('getSchema', () => {
})

it('fails to parse when seats is not a number', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({ accountDetails, minSeats: 5 })

const response = schema.safeParse({ seats: 'ahh' })
Expand All @@ -269,9 +255,6 @@ describe('getSchema', () => {
})

it('fails to parse when the seats are below the minimum', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({ accountDetails, minSeats: 5 })

const response = schema.safeParse({ seats: 3 })
Expand Down Expand Up @@ -303,9 +286,6 @@ describe('getSchema', () => {
})

it('passes when seats are below activated seats and user is on trial', () => {
const accountDetails = {
activatedUserCount: 2,
} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({
accountDetails,
minSeats: 5,
Expand All @@ -321,8 +301,9 @@ describe('getSchema', () => {
})

describe('when the user upgrades to team plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>

it('fails to parse when seats are above max seats', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({
accountDetails,
selectedPlan: {
Expand All @@ -345,7 +326,6 @@ describe('getSchema', () => {
})

it('passes when seats are below max seats for team yearly plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({
accountDetails,
selectedPlan: {
Expand All @@ -364,7 +344,6 @@ describe('getSchema', () => {
})

it('passes when seats are below max seats for team monthly plan', () => {
const accountDetails = {} as z.infer<typeof AccountDetailsSchema>
const schema = getSchema({
accountDetails,
selectedPlan: {
Expand Down

0 comments on commit 91efa0a

Please sign in to comment.