Skip to content

Commit

Permalink
eslint: Address error and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Oct 24, 2023
1 parent 7245c78 commit 1c09553
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
30 changes: 10 additions & 20 deletions apps/api/src/affiliate/affiliate.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ describe('AffiliateController', () => {
describe('Join program request', () => {
it('should throw error if request is from individual profile', async () => {
const createAffiliateSpy = jest.spyOn(service, 'create')
const findOneSpy = jest
.spyOn(prismaMock.person, 'findFirst')
.mockResolvedValue(mockIndividualProfile)
jest.spyOn(prismaMock.person, 'findFirst').mockResolvedValue(mockIndividualProfile)
expect(controller.joinAffiliateProgramRequest(userMock)).rejects.toThrow(
new BadRequestException('Must be corporate profile'),
)
Expand All @@ -183,9 +181,7 @@ describe('AffiliateController', () => {
},
}
const createAffiliateSpy = jest.spyOn(service, 'create').mockResolvedValue(affiliateMock)
const findOneSpy = jest
.spyOn(prismaMock.person, 'findFirst')
.mockResolvedValue(mockCorporateProfile)
jest.spyOn(prismaMock.person, 'findFirst').mockResolvedValue(mockCorporateProfile)

expect(await controller.joinAffiliateProgramRequest(userMock)).toEqual(affiliateMock)
expect(createAffiliateSpy).toHaveBeenCalled()
Expand All @@ -208,7 +204,7 @@ describe('AffiliateController', () => {
...userMock,
resource_access: { account: { roles: ['manage-account', 'account-view-supporters'] } },
}
const findAffiliateSpy = jest.spyOn(service, 'findOneById').mockResolvedValue(affiliateMock)
jest.spyOn(service, 'findOneById').mockResolvedValue(affiliateMock)

const codeGenerationSpy = jest
.spyOn(afCodeGenerator, 'affiliateCodeGenerator')
Expand Down Expand Up @@ -241,9 +237,7 @@ describe('AffiliateController', () => {
const mockCancelledStatus: AffiliateStatusUpdateDto = {
newStatus: 'cancelled',
}
const findAffiliateSpy = jest
.spyOn(service, 'findOneById')
.mockResolvedValue(activeAffiliateMock)
jest.spyOn(service, 'findOneById').mockResolvedValue(activeAffiliateMock)

const codeGenerationSpy = jest
.spyOn(afCodeGenerator, 'affiliateCodeGenerator')
Expand All @@ -265,9 +259,7 @@ describe('AffiliateController', () => {
resource_access: { account: { roles: ['manage-account', 'account-view-supporters'] } },
}

const findAffiliateSpy = jest
.spyOn(service, 'findOneById')
.mockResolvedValue(activeAffiliateMock)
jest.spyOn(service, 'findOneById').mockResolvedValue(activeAffiliateMock)

const updateStatusDto: AffiliateStatusUpdateDto = {
newStatus: 'active',
Expand Down Expand Up @@ -302,11 +294,11 @@ describe('AffiliateController', () => {
currency: 'BGN',
toEntity: new CreateAffiliateDonation().toEntity,
}
const prismaSpy = jest.spyOn(service, 'findOneByCode').mockResolvedValue(activeAffiliateMock)
jest.spyOn(service, 'findOneByCode').mockResolvedValue(activeAffiliateMock)
const createAffiliateDonationSpy = jest
.spyOn(donationService, 'createAffiliateDonation')
.mockResolvedValue(donationResponseMock)
const findVaultSpy = jest.spyOn(prismaMock.vault, 'findMany').mockResolvedValue([vaultMock])
jest.spyOn(prismaMock.vault, 'findMany').mockResolvedValue([vaultMock])
await controller.createAffiliateDonation(affiliateCodeMock, affiliateDonationDto)
expect(createAffiliateDonationSpy).toHaveBeenCalledWith({
...affiliateDonationDto,
Expand All @@ -321,12 +313,10 @@ describe('AffiliateController', () => {
...donationResponseMock,
status: 'cancelled',
}
const affiliateDonationSpy = jest
jest
.spyOn(donationService, 'getAffiliateDonationById')
.mockResolvedValue(donationResponseMock)
const updateDonationStatus = jest
.spyOn(donationService, 'update')
.mockResolvedValue(cancelledDonationResponse)
jest.spyOn(donationService, 'update').mockResolvedValue(cancelledDonationResponse)
expect(
await controller.cancelAffiliateDonation(affiliateCodeMock, donationResponseMock.id),
).toEqual(cancelledDonationResponse)
Expand All @@ -337,7 +327,7 @@ describe('AffiliateController', () => {
status: 'succeeded',
}

const affiliateDonationSpy = jest
jest
.spyOn(donationService, 'getAffiliateDonationById')
.mockResolvedValue(succeededDonationResponse)
const updateDonationStatus = jest.spyOn(donationService, 'update')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class CreateAffiliateDonation {

@IsString()
@IsOptional()
extPaymentMethodId: string = 'affiliate'
extPaymentMethodId = 'affiliate'

@ApiProperty()
@Expose()
Expand Down

0 comments on commit 1c09553

Please sign in to comment.