mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
d2974a9ff6
* refactor(adapters): convert adapter layer from TypeScript to JavaScript Core framework stays TypeScript; adapter layer moves to JS-first. Adapters are essentially "executable config + browser scripts" that barely use TS features — this simplifies the build/distribution pipeline by removing the dist/clis/ intermediate compilation step. Changes: - Convert all 753 adapter files in clis/ from .ts to .js - Update tsconfig to exclude clis/ from compilation - Simplify build-manifest to scan clis/*.js directly (no dist/clis/) - Update discovery, main, fetch-adapters to load JS adapters from clis/ - Update generate-verified to output .js artifacts - Update package.json files field: dist/clis/ → clis/ - Fix all test files for the .ts → .js transition * fix(main): use findPackageRoot for BUILTIN_CLIS path The previous relative path (../../clis from __dirname) only worked for dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname is <repo>/src — resolving to /clis instead of <repo>/clis. Use findPackageRoot() which works for both dev and prod paths.
30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
import { describe, expect, it } from 'vitest';
|
|
import { __test__ } from './offer.js';
|
|
describe('amazon offer normalization', () => {
|
|
it('extracts sold-by and fulfillment facts from product offer text', () => {
|
|
const result = __test__.normalizeOfferPayload({
|
|
href: 'https://www.amazon.com/dp/B0FJS72893',
|
|
price_text: '$15.99',
|
|
merchant_info: '',
|
|
sold_by: 'KUATUDIRECT',
|
|
ships_from_text: 'Ships from Amazon',
|
|
offer_link: null,
|
|
review_url: 'https://www.amazon.com/dp/B0FJS72893#customerReviews',
|
|
qa_url: null,
|
|
});
|
|
expect(result.asin).toBe('B0FJS72893');
|
|
expect(result.sold_by).toBe('KUATUDIRECT');
|
|
expect(result.ships_from).toBe('Amazon');
|
|
expect(result.is_amazon_sold).toBe(false);
|
|
expect(result.is_amazon_fulfilled).toBe(true);
|
|
});
|
|
it('parses merchant info fallback text', () => {
|
|
expect(__test__.extractSoldBy('Sold by Example Seller and Fulfilled by Amazon.')).toBe('Example Seller');
|
|
expect(__test__.extractShipsFrom('Ships from Amazon')).toBe('Amazon');
|
|
});
|
|
it('detects delivery-location blocking in the buy box text', () => {
|
|
expect(__test__.isDeliveryLocationBlocked('This item cannot be shipped to your selected delivery location. Similar items shipping to Hong Kong')).toBe(true);
|
|
expect(__test__.isDeliveryLocationBlocked('Ships from Amazon')).toBe(false);
|
|
});
|
|
});
|