// noinspection TypeScriptUnresolvedReference
|
|
import {describe, expect, it} from 'vitest';
|
import {getSearchProvider} from '../src/search-providers';
|
import {ISearchParams, StationId} from '../src/type';
|
|
describe('provider', () => {
|
it('Provider2Mercari', () => exeTestProvider({stationId: StationId.Mercari}), 30000);
|
// it('Provider4YahooAuction', () => exeTestProvider({stationId: StationId.YahooAuction}), 30000);
|
it('Provider4YahooAuction', () => exeTestProvider({
|
"shipping": "free",
|
"max": 50,
|
"minPrice": 3000,
|
"sort": "default",
|
"maxPrice": 5000,
|
"keyword": "百合",
|
"category": "21600",
|
"begin": 1,
|
"stationId": 4
|
} as any), 30000);
|
it('Provider5Melonbooks', () => exeTestProvider({stationId: StationId.Melonbooks}), 30000);
|
it('Provider6Toranoana', () => exeTestProvider({stationId: StationId.Toranoana}), 30000);
|
it('Provider7Booth', () => exeTestProvider({stationId: StationId.Booth, begin: 61, category: 'Comics'}), 30000);
|
it('Provider8Mandarake', () => exeTestProvider({stationId: StationId.Mandarake}), 30000);
|
it('Provider9Fril', () => exeTestProvider({stationId: StationId.Fril}), 30000);
|
it('Provider10YahooFleamarket', () => exeTestProvider({stationId: StationId.YahooFleamarket}), 30000);
|
});
|
|
const defaultParams: ISearchParams = {keyword: 'DVD'};
|
|
async function exeTestProvider(params: Partial<ISearchParams>) {
|
const provider = getSearchProvider(params.stationId);
|
const result = await provider.search({...defaultParams, ...params});
|
// Check that the result object has the expected structure
|
expect(result).toBeTypeOf('object');
|
expect(result.dataList).toBeInstanceOf(Array);
|
console.clear();
|
console.log('last request:')
|
console.log(result)
|
|
// If there are items, check the structure of the first item
|
if (result.dataList.length > 0) {
|
const item = result.dataList[0];
|
expect(item).toHaveProperty('itemId');
|
expect(item).toHaveProperty('name');
|
expect(item).toHaveProperty('price');
|
expect(item).toHaveProperty('url');
|
}
|
const out: any = {...result}
|
out.dataList = result.dataList.length;
|
console.log(out)
|
console.log(result.dataList[0])
|
}
|