lefengyang
2026-08-20 d01a28cb030b2cb0ff1d42273c877a0f728519a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 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])
}