feat: shop detection from URL + vitest setup
This commit is contained in:
22
tests/shops.test.ts
Normal file
22
tests/shops.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { detectShop } from '@/lib/shops'
|
||||
|
||||
describe('detectShop', () => {
|
||||
it.each([
|
||||
['https://www.amazon.de/dp/B0C5BMMJTL', 'amazon'],
|
||||
['https://amazon.com/gp/product/B0C5BMMJTL', 'amazon'],
|
||||
['https://www.idealo.de/preisvergleich/OffersOfProduct/123456_-foo.html', 'idealo'],
|
||||
['https://geizhals.de/sony-playstation-5-a2362829.html', 'geizhals'],
|
||||
['https://www.geizhals.eu/foo', 'geizhals'],
|
||||
])('detects %s as %s', (url, expected) => {
|
||||
expect(detectShop(url)).toBe(expected)
|
||||
})
|
||||
|
||||
it('returns null for unknown shop', () => {
|
||||
expect(detectShop('https://example.com/foo')).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null for invalid url', () => {
|
||||
expect(detectShop('not a url')).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user