|
|
@ -3,12 +3,18 @@ import { DataSource } from '@prisma/client'; |
|
|
import { SymbolProfileService } from './symbol-profile.service'; |
|
|
import { SymbolProfileService } from './symbol-profile.service'; |
|
|
|
|
|
|
|
|
describe('SymbolProfileService', () => { |
|
|
describe('SymbolProfileService', () => { |
|
|
let prismaService: { symbolProfile: { findMany: jest.Mock } }; |
|
|
|
|
|
let symbolProfileService: SymbolProfileService; |
|
|
let symbolProfileService: SymbolProfileService; |
|
|
|
|
|
|
|
|
|
|
|
let prismaService: { |
|
|
|
|
|
symbolProfile: { findMany: jest.Mock; findUnique: jest.Mock }; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
beforeEach(() => { |
|
|
prismaService = { |
|
|
prismaService = { |
|
|
symbolProfile: { findMany: jest.fn().mockResolvedValue([]) } |
|
|
symbolProfile: { |
|
|
|
|
|
findMany: jest.fn().mockResolvedValue([]), |
|
|
|
|
|
findUnique: jest.fn().mockResolvedValue(null) |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
symbolProfileService = new SymbolProfileService(prismaService as any); |
|
|
symbolProfileService = new SymbolProfileService(prismaService as any); |
|
|
@ -16,9 +22,9 @@ describe('SymbolProfileService', () => { |
|
|
|
|
|
|
|
|
describe('getSymbolOfAssetProfile', () => { |
|
|
describe('getSymbolOfAssetProfile', () => { |
|
|
it('Keeps the symbol of the existing asset profile', async () => { |
|
|
it('Keeps the symbol of the existing asset profile', async () => { |
|
|
prismaService.symbolProfile.findMany.mockResolvedValue([ |
|
|
prismaService.symbolProfile.findUnique.mockResolvedValue({ |
|
|
{ symbol: 'AAPL' } |
|
|
symbol: 'AAPL' |
|
|
]); |
|
|
}); |
|
|
|
|
|
|
|
|
const symbol = await symbolProfileService.getSymbolOfAssetProfile({ |
|
|
const symbol = await symbolProfileService.getSymbolOfAssetProfile({ |
|
|
dataSource: DataSource.YAHOO, |
|
|
dataSource: DataSource.YAHOO, |
|
|
@ -27,6 +33,7 @@ describe('SymbolProfileService', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect(symbol).toEqual('AAPL'); |
|
|
expect(symbol).toEqual('AAPL'); |
|
|
|
|
|
expect(prismaService.symbolProfile.findMany).not.toHaveBeenCalled(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('Keeps the letter case of the existing asset profile', async () => { |
|
|
it('Keeps the letter case of the existing asset profile', async () => { |
|
|
@ -100,6 +107,7 @@ describe('SymbolProfileService', () => { |
|
|
|
|
|
|
|
|
expect(symbol).toEqual('GF_apple'); |
|
|
expect(symbol).toEqual('GF_apple'); |
|
|
expect(prismaService.symbolProfile.findMany).not.toHaveBeenCalled(); |
|
|
expect(prismaService.symbolProfile.findMany).not.toHaveBeenCalled(); |
|
|
|
|
|
expect(prismaService.symbolProfile.findUnique).not.toHaveBeenCalled(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|