chore: CRM-NEW baseline
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { translateProductQuery } = require('../src/product-query');
|
||||
|
||||
test('translateProductQuery: Chinese category alias -> English title', () => {
|
||||
const entries = [
|
||||
{ title: 'Rings', category: 'jewelry/rings', url: 'https://www.yehwang.com/jewelry/rings', aliases: ['戒指', 'ringen'] },
|
||||
{ title: 'Earrings', category: 'jewelry/earrings', url: 'https://www.yehwang.com/jewelry/earrings', aliases: ['耳环'] },
|
||||
];
|
||||
const out = translateProductQuery('简约不锈钢戒指', entries);
|
||||
assert.equal(out.translated, true);
|
||||
assert.equal(out.query, 'Rings');
|
||||
assert.equal(out.category.url, 'https://www.yehwang.com/jewelry/rings');
|
||||
});
|
||||
|
||||
test('translateProductQuery: English query unchanged', () => {
|
||||
const out = translateProductQuery('hoop earrings', []);
|
||||
assert.equal(out.translated, false);
|
||||
assert.equal(out.query, 'hoop earrings');
|
||||
});
|
||||
Reference in New Issue
Block a user