TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { readFileSync } from 'node:fs';2import path from 'node:path';3import { describe, expect, it } from 'vitest';4import { getConnectorMeta } from '@rareindex/connectors';5import { fixtureDir, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';6import createConnector, { searchUrl, toItem } from './index.js';78const connector = createConnector(getConnectorMeta('bunjang'));9const sample = JSON.parse(readFileSync(path.join(fixtureDir('bunjang'), 'samples', 'find-v2.json'), 'utf8')) as { num_found: number; list: Record<string, unknown>[] };1011describe('bunjang', () => {12 runFixtureSuite(connector, it, expect);1314 it('maps a raw find_v2 row (KRW price string, image template, status, category)', () => {15 const it0 = toItem(sample.list[0]!);16 expect(it0).not.toBeNull();17 expect(it0!.pid).toBe('407596186');18 expect(it0!.price).toBe(100000);19 expect(it0!.image).toBe('https://media.bunjang.co.kr/product/407596186_1_1778563857_w600.jpg');20 expect(it0!.status).toBe('0');21 expect(it0!.categoryId).toBe('940100001');22 expect(it0!.used).toBe(2);23 expect(sample.num_found).toBeGreaterThan(100);24 expect(toItem({ ...sample.list[0]!, type: 'BANNER' })).toBeNull();25 });2627 it('builds the 0-based search URL', () => {28 expect(searchUrl('포켓몬카드', 2)).toBe('https://api.bunjang.co.kr/api/1/find_v2.json?q=%ED%8F%AC%EC%BC%93%EB%AA%AC%EC%B9%B4%EB%93%9C&order=date&page=2&n=100&req_ref=search&stat_device=w&version=5');29 });3031 it('normalises the fixture into KRW listings with grade, condition, language and metadata', async () => {32 const fx = loadFixture('bunjang', 'pokemon-psa10-search-p0');33 const out = await connector.normalize(fx.raw);34 expect(out.length).toBeGreaterThan(5);35 const l = out[0];36 if (l?.kind !== 'listing') throw new Error('expected listing');37 expect(l.currency).toBe('KRW');38 expect(l.price).toBe(100000);39 expect(l.attributes.categorySlug).toBe('pokemon');40 expect(l.attributes.identifiers.bunjang_pid).toBe('407596186');41 expect(l.attributes.language).toBe('English'); // 북미판 = North American print42 expect(l.grade.grader).toBe('psa');43 expect(l.grade.grade).toBe('10');44 expect(l.condition.conditionRaw).toBe('Used'); // used = 245 expect(l.availability).toBe('available');46 expect(l.listedAt).toBeNull();47 expect(typeof l.attributes.metadata.updated_at).toBe('string');48 expect(l.sourceUrl).toBe('https://m.bunjang.co.kr/products/407596186');49 expect(l.seller).toBeNull();50 const jp = out.find((r) => r.kind === 'listing' && /일판/.test(r.rawTitle));51 expect(jp && jp.kind === 'listing' ? jp.attributes.language : null).toBe('Japanese');52 });53});54