mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-08 15:05:22 +02:00
remove plaid from more tests
This commit is contained in:
parent
0b505d4a66
commit
bc2b2492e7
3 changed files with 29 additions and 36 deletions
|
@ -1,21 +1,18 @@
|
|||
import type { AxiosInstance } from 'axios'
|
||||
import type { SharedType } from '@maybe-finance/shared'
|
||||
import type { Prisma, AccountConnection, AccountSyncStatus, User } from '@prisma/client'
|
||||
import type { ItemRemoveResponse } from 'plaid'
|
||||
import type { Prisma, AccountConnection, User } from '@prisma/client'
|
||||
import { startServer, stopServer } from './utils/server'
|
||||
import { getAxiosClient } from './utils/axios'
|
||||
import prisma from '../lib/prisma'
|
||||
import { TestUtil } from '@maybe-finance/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 { resetUser } from './utils/user'
|
||||
|
||||
jest.mock('../middleware/validate-plaid-jwt.ts')
|
||||
jest.mock('plaid')
|
||||
jest.mock('../lib/teller.ts')
|
||||
|
||||
// For TypeScript support
|
||||
const plaid = jest.mocked(_plaid)
|
||||
const teller = jest.mocked(_teller)
|
||||
|
||||
const authId = '__TEST_USER_ID__'
|
||||
let axios: AxiosInstance
|
||||
|
@ -49,13 +46,13 @@ beforeEach(async () => {
|
|||
connectionData = {
|
||||
data: {
|
||||
name: 'Chase Test',
|
||||
type: 'plaid' as SharedType.AccountConnectionType,
|
||||
plaidItemId: 'test-plaid-item-server',
|
||||
plaidInstitutionId: 'ins_3',
|
||||
plaidAccessToken:
|
||||
'U2FsdGVkX1+WMq9lfTS9Zkbgrn41+XT1hvSK5ain/udRPujzjVCAx/lyPG7EumVZA+nVKXPauGwI+d7GZgtqTA9R3iCZNusU6LFPnmFOCE4=',
|
||||
userId: user!.id,
|
||||
syncStatus: 'PENDING' as AccountSyncStatus,
|
||||
type: 'teller' as SharedType.AccountConnectionType,
|
||||
tellerEnrollmentId: 'test-teller-item-workers',
|
||||
tellerInstitutionId: 'chase_test',
|
||||
tellerAccessToken:
|
||||
'U2FsdGVkX1+WMq9lfTS9Zkbgrn41+XT1hvSK5ain/udRPujzjVCAx/lyPG7EumVZA+nVKXPauGwI+d7GZgtqTA9R3iCZNusU6LFPnmFOCE4=', // need correct encoding here
|
||||
userId: user.id,
|
||||
syncStatus: 'PENDING',
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -91,16 +88,9 @@ describe('/v1/connections API', () => {
|
|||
})
|
||||
|
||||
it('DELETE /:id', async () => {
|
||||
plaid.itemRemove.mockResolvedValueOnce(
|
||||
TestUtil.axiosSuccess<ItemRemoveResponse>({
|
||||
request_id: 'test request id',
|
||||
})
|
||||
)
|
||||
|
||||
const res = await axios.delete<AccountConnection>(`/connections/${connection.id}`)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(plaid.itemRemove).toHaveBeenCalledTimes(1)
|
||||
|
||||
const res2 = await axios.get<AccountConnection>(`/connections/${connection.id}`)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { User } from '@prisma/client'
|
||||
import { InvestmentTransactionCategory, type User } from '@prisma/client'
|
||||
import { Prisma, PrismaClient } from '@prisma/client'
|
||||
import { createLogger, transports } from 'winston'
|
||||
import { DateTime } from 'luxon'
|
||||
|
@ -305,8 +305,7 @@ describe('insight service', () => {
|
|||
amount: 50 * 100,
|
||||
quantity: 50,
|
||||
price: 100,
|
||||
plaidType: 'buy',
|
||||
plaidSubtype: 'buy',
|
||||
category: InvestmentTransactionCategory.buy,
|
||||
},
|
||||
{
|
||||
accountId: account.id,
|
||||
|
@ -316,8 +315,7 @@ describe('insight service', () => {
|
|||
amount: 10 * 200,
|
||||
quantity: 10,
|
||||
price: 200,
|
||||
plaidType: 'buy',
|
||||
plaidSubtype: 'buy',
|
||||
category: InvestmentTransactionCategory.buy,
|
||||
},
|
||||
{
|
||||
accountId: account.id,
|
||||
|
@ -327,8 +325,7 @@ describe('insight service', () => {
|
|||
amount: -20.22,
|
||||
quantity: 0,
|
||||
price: 0,
|
||||
plaidType: 'cash',
|
||||
plaidSubtype: 'dividend',
|
||||
category: InvestmentTransactionCategory.dividend,
|
||||
},
|
||||
{
|
||||
accountId: account.id,
|
||||
|
@ -338,8 +335,7 @@ describe('insight service', () => {
|
|||
amount: -22.85,
|
||||
quantity: 0,
|
||||
price: 0,
|
||||
plaidType: 'cash',
|
||||
plaidSubtype: 'dividend',
|
||||
category: InvestmentTransactionCategory.dividend,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
|
|
@ -8,22 +8,29 @@ const prisma = new PrismaClient()
|
|||
*/
|
||||
async function main() {
|
||||
const institutions: (Pick<Institution, 'id' | 'name'> & {
|
||||
providers: { provider: Provider; providerId: string; rank?: number }[]
|
||||
providers: { provider: Provider; providerId: string; logoUrl: string; rank?: number }[]
|
||||
})[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Capital One',
|
||||
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,
|
||||
name: 'Discover Bank',
|
||||
name: 'Wells Fargo',
|
||||
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',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue