1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 23:15:24 +02:00

remove plaid from more tests

This commit is contained in:
Tyler Myracle 2024-01-19 17:52:07 -06:00
parent 0b505d4a66
commit bc2b2492e7
3 changed files with 29 additions and 36 deletions

View file

@ -1,21 +1,18 @@
import type { AxiosInstance } from 'axios' import type { AxiosInstance } from 'axios'
import type { SharedType } from '@maybe-finance/shared' import type { SharedType } from '@maybe-finance/shared'
import type { Prisma, AccountConnection, AccountSyncStatus, User } from '@prisma/client' import type { Prisma, AccountConnection, User } from '@prisma/client'
import type { ItemRemoveResponse } from 'plaid'
import { startServer, stopServer } from './utils/server' import { startServer, stopServer } from './utils/server'
import { getAxiosClient } from './utils/axios' import { getAxiosClient } from './utils/axios'
import prisma from '../lib/prisma' import prisma from '../lib/prisma'
import { TestUtil } from '@maybe-finance/shared'
import { InMemoryQueue } from '@maybe-finance/server/shared' import { InMemoryQueue } from '@maybe-finance/server/shared'
import { default as _plaid } from '../lib/plaid' import { default as _teller } from '../lib/teller'
import nock from 'nock' import nock from 'nock'
import { resetUser } from './utils/user' import { resetUser } from './utils/user'
jest.mock('../middleware/validate-plaid-jwt.ts') jest.mock('../lib/teller.ts')
jest.mock('plaid')
// For TypeScript support // For TypeScript support
const plaid = jest.mocked(_plaid) const teller = jest.mocked(_teller)
const authId = '__TEST_USER_ID__' const authId = '__TEST_USER_ID__'
let axios: AxiosInstance let axios: AxiosInstance
@ -49,13 +46,13 @@ beforeEach(async () => {
connectionData = { connectionData = {
data: { data: {
name: 'Chase Test', name: 'Chase Test',
type: 'plaid' as SharedType.AccountConnectionType, type: 'teller' as SharedType.AccountConnectionType,
plaidItemId: 'test-plaid-item-server', tellerEnrollmentId: 'test-teller-item-workers',
plaidInstitutionId: 'ins_3', tellerInstitutionId: 'chase_test',
plaidAccessToken: tellerAccessToken:
'U2FsdGVkX1+WMq9lfTS9Zkbgrn41+XT1hvSK5ain/udRPujzjVCAx/lyPG7EumVZA+nVKXPauGwI+d7GZgtqTA9R3iCZNusU6LFPnmFOCE4=', 'U2FsdGVkX1+WMq9lfTS9Zkbgrn41+XT1hvSK5ain/udRPujzjVCAx/lyPG7EumVZA+nVKXPauGwI+d7GZgtqTA9R3iCZNusU6LFPnmFOCE4=', // need correct encoding here
userId: user!.id, userId: user.id,
syncStatus: 'PENDING' as AccountSyncStatus, syncStatus: 'PENDING',
}, },
} }
@ -91,16 +88,9 @@ describe('/v1/connections API', () => {
}) })
it('DELETE /:id', async () => { it('DELETE /:id', async () => {
plaid.itemRemove.mockResolvedValueOnce(
TestUtil.axiosSuccess<ItemRemoveResponse>({
request_id: 'test request id',
})
)
const res = await axios.delete<AccountConnection>(`/connections/${connection.id}`) const res = await axios.delete<AccountConnection>(`/connections/${connection.id}`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(plaid.itemRemove).toHaveBeenCalledTimes(1)
const res2 = await axios.get<AccountConnection>(`/connections/${connection.id}`) const res2 = await axios.get<AccountConnection>(`/connections/${connection.id}`)

View file

@ -1,4 +1,4 @@
import type { User } from '@prisma/client' import { InvestmentTransactionCategory, type User } from '@prisma/client'
import { Prisma, PrismaClient } from '@prisma/client' import { Prisma, PrismaClient } from '@prisma/client'
import { createLogger, transports } from 'winston' import { createLogger, transports } from 'winston'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
@ -305,8 +305,7 @@ describe('insight service', () => {
amount: 50 * 100, amount: 50 * 100,
quantity: 50, quantity: 50,
price: 100, price: 100,
plaidType: 'buy', category: InvestmentTransactionCategory.buy,
plaidSubtype: 'buy',
}, },
{ {
accountId: account.id, accountId: account.id,
@ -316,8 +315,7 @@ describe('insight service', () => {
amount: 10 * 200, amount: 10 * 200,
quantity: 10, quantity: 10,
price: 200, price: 200,
plaidType: 'buy', category: InvestmentTransactionCategory.buy,
plaidSubtype: 'buy',
}, },
{ {
accountId: account.id, accountId: account.id,
@ -327,8 +325,7 @@ describe('insight service', () => {
amount: -20.22, amount: -20.22,
quantity: 0, quantity: 0,
price: 0, price: 0,
plaidType: 'cash', category: InvestmentTransactionCategory.dividend,
plaidSubtype: 'dividend',
}, },
{ {
accountId: account.id, accountId: account.id,
@ -338,8 +335,7 @@ describe('insight service', () => {
amount: -22.85, amount: -22.85,
quantity: 0, quantity: 0,
price: 0, price: 0,
plaidType: 'cash', category: InvestmentTransactionCategory.dividend,
plaidSubtype: 'dividend',
}, },
], ],
}) })

View file

@ -8,22 +8,29 @@ const prisma = new PrismaClient()
*/ */
async function main() { async function main() {
const institutions: (Pick<Institution, 'id' | 'name'> & { const institutions: (Pick<Institution, 'id' | 'name'> & {
providers: { provider: Provider; providerId: string; rank?: number }[] providers: { provider: Provider; providerId: string; logoUrl: string; rank?: number }[]
})[] = [ })[] = [
{ {
id: 1, id: 1,
name: 'Capital One', name: 'Capital One',
providers: [ providers: [
{ provider: 'PLAID', providerId: 'ins_9', rank: 1 }, {
{ provider: 'FINICITY', providerId: '170778' }, provider: 'TELLER',
providerId: 'capital_one',
logoUrl: 'https://teller.io/images/banks/capital_one.jpg',
rank: 1,
},
], ],
}, },
{ {
id: 2, id: 2,
name: 'Discover Bank', name: 'Wells Fargo',
providers: [ providers: [
{ provider: 'PLAID', providerId: 'ins_33' }, {
{ provider: 'FINICITY', providerId: '13796', rank: 1 }, provider: 'TELLER',
providerId: 'wells_fargo',
logoUrl: 'https://teller.io/images/banks/wells_fargo.jpg',
},
], ],
}, },
] ]