You've already forked tf2wikipricing
refactor: fetchPrice now expects an SKU string
This commit is contained in:
@@ -49,7 +49,7 @@ describe('Price Service', () => {
|
||||
test('fetchPrice returns cached data if available and not expired', async () => {
|
||||
(getStorageValue as jest.Mock).mockResolvedValue(mockCachedData)
|
||||
|
||||
const result = await fetchPrice(mockToken, mockDefIndex, mockQuality)
|
||||
const result = await fetchPrice(mockToken, mockDefIndex + ";" + mockQuality)
|
||||
|
||||
expect(getStorageValue).toHaveBeenCalledWith(expect.stringContaining(mockSku), null)
|
||||
expect(result).toEqual(mockCachedData)
|
||||
@@ -60,7 +60,7 @@ describe('Price Service', () => {
|
||||
(getStorageValue as jest.Mock).mockResolvedValue(expiredCache);
|
||||
(priceUsingPricesTF as jest.Mock).mockResolvedValue(mockPriceResponse)
|
||||
|
||||
const result = await fetchPrice(mockToken, mockDefIndex, mockQuality)
|
||||
const result = await fetchPrice(mockToken, mockDefIndex + ";" + mockQuality)
|
||||
|
||||
expect(priceUsingPricesTF).toHaveBeenCalledWith(mockToken, `${mockDefIndex};${mockQuality}`)
|
||||
expect(setStorageValue).toHaveBeenCalled()
|
||||
@@ -69,7 +69,7 @@ describe('Price Service', () => {
|
||||
})
|
||||
|
||||
test('fetchPrice rejects with 401 when no token provided', async () => {
|
||||
await expect(fetchPrice('', mockDefIndex, mockQuality)).rejects.toBe(401)
|
||||
await expect(fetchPrice('', mockDefIndex + ";" + mockQuality)).rejects.toBe(401)
|
||||
})
|
||||
|
||||
test('fetchPrice handles pricing API errors', async () => {
|
||||
@@ -77,7 +77,7 @@ describe('Price Service', () => {
|
||||
(priceUsingPricesTF as jest.Mock).mockRejectedValue(testError);
|
||||
(getStorageValue as jest.Mock).mockResolvedValue(null)
|
||||
|
||||
await expect(fetchPrice(mockToken, mockDefIndex, mockQuality)).rejects.toBe(testError)
|
||||
await expect(fetchPrice(mockToken, mockDefIndex + ";" + mockQuality)).rejects.toBe(testError)
|
||||
})
|
||||
|
||||
test('fetchKeyPrice uses correct parameters', async () => {
|
||||
|
||||
Reference in New Issue
Block a user