@vtex/vtexis-compatibility-layer
Version:
Compatibility layer between intelligent search and VTEX
86 lines (85 loc) • 4.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const convertISProduct_1 = require("../convertISProduct");
const biggyProduct_1 = require("./mock/biggyProduct");
const vtexProduct_1 = require("./mock/vtexProduct");
let biggyProduct;
let convertedVtexProduct;
let convertedSearchItems;
describe('convertISProduct', () => {
beforeAll(() => {
biggyProduct = { ...biggyProduct_1.biggyProductMock };
convertedVtexProduct = convertISProduct_1.convertISProduct(biggyProduct);
convertedSearchItems = convertedVtexProduct.items;
});
it('should convert brand information properly', () => {
const { brand, brandId } = convertedVtexProduct;
expect(brand).toBe(vtexProduct_1.vtexProductMock.brand);
expect(brandId).toBe(vtexProduct_1.vtexProductMock.brandId);
});
it('should convert category information properly', () => {
const { categoryId, categories } = convertedVtexProduct;
expect(categoryId).toBe(vtexProduct_1.vtexProductMock.categoryId);
expect(categories).toMatchObject(vtexProduct_1.vtexProductMock.categories);
// We don't support to category tree currently
// expect(categoryTree).toMatchObject(vtexProductMock.categoryTree)
});
it('should convert productClusters and clusterHighLights properly', () => {
const { clusterHighlights, productClusters } = convertedVtexProduct;
expect(clusterHighlights).toMatchObject(vtexProduct_1.vtexProductMock.clusterHighlights);
expect(productClusters).toMatchObject(vtexProduct_1.vtexProductMock.productClusters);
});
it('should convert description properly', () => {
const { description } = convertedVtexProduct;
expect(description).toBe(vtexProduct_1.vtexProductMock.description);
});
it('should convert skuSpecifications properly', () => {
const { skuSpecifications } = convertedVtexProduct;
expect(skuSpecifications).toMatchObject(vtexProduct_1.vtexProductMock.skuSpecifications);
});
it('should convert link information properly', () => {
const { linkText } = convertedVtexProduct;
expect(linkText).toBe(vtexProduct_1.vtexProductMock.linkText);
});
it('should convert productId properly', () => {
const { productId } = convertedVtexProduct;
expect(productId).toBe(vtexProduct_1.vtexProductMock.productId);
});
it('should convert name information properly', () => {
const { productName } = convertedVtexProduct;
expect(productName).toBe(vtexProduct_1.vtexProductMock.productName);
});
it('should convert productReference properly', () => {
const { productReference } = convertedVtexProduct;
expect(productReference).toBe(vtexProduct_1.vtexProductMock.productReference);
});
it('should convert priceRange properly', () => {
const { priceRange } = convertedVtexProduct;
expect(priceRange).toMatchObject(vtexProduct_1.vtexProductMock.priceRange);
});
it('should convert specifications info properly', () => {
const { skuSpecifications, specificationGroups, properties } = convertedVtexProduct;
expect(skuSpecifications).toMatchObject(vtexProduct_1.vtexProductMock.skuSpecifications);
// FIXME: https://vtex-dev.atlassian.net/browse/PER-3403
// vtexProductMock.specificationGroups.forEach((specification) => {
// expect(specificationGroups).toEqual(
// expect.arrayContaining([
// expect.objectContaining({
// name: specification.name,
// originalName: specification.originalName,
// specifications: expect.arrayContaining([...specification.specifications]),
// }),
// ])
// )
// })
vtexProduct_1.vtexProductMock.properties.forEach((property) => {
expect(properties).toEqual(expect.arrayContaining([property]));
});
});
it('should covert items in the correct order', () => {
expect(convertedSearchItems).toHaveLength(vtexProduct_1.vtexProductMock.items.length);
convertedSearchItems.forEach((item, idx) => {
expect(item.itemId).toBe(vtexProduct_1.vtexProductMock.items[idx].itemId);
});
});
});