5180 fichiers 38.5 Mo 0 téléchargements 215 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / api / catalog / Offer.test.ts
Offer.test.ts 1.8 Ko Télécharger le fichier
// @vitest-environment jsdom
import { describe, expect, it } from 'vitest';
import { Offer } from './Offer';
import { Product } from './Product';
import { ProductTypeEnum } from './ProductTypeEnum';

const product = (type: string, classId: number, extraParam: string) => new Product(type, classId, extraParam, 1, null, null);

const offer = (products: Product[]) => new Offer(1, 'chat_bubble_40', false, 5, 0, 0, false, 0, products, false);

describe('Offer chat style products (AIR 13 PRODUCT_TYPE_CHAT_STYLE)', () => {
    it('sells a chat style alone as a single product', () => {
        const chatStyle = offer([product('CHAT_STYLE', 40, '40')]);

        expect(chatStyle.isChatStyleOffer).toBe(true);
        expect(chatStyle.pricingModel).toBe(Offer.PRICING_MODEL_SINGLE);
        expect(chatStyle.product.productType).toBe(ProductTypeEnum.CHAT_STYLE);
        expect(chatStyle.chatStyleId).toBeNull();
    });

    it('sells a chat style with a badge as the chat style, with the badge as add-on', () => {
        const bundle = offer([product(ProductTypeEnum.BADGE, 0, 'ACH_1'), product(ProductTypeEnum.CHAT_STYLE, 40, '40')]);

        expect(bundle.isChatStyleOffer).toBe(true);
        expect(bundle.pricingModel).toBe(Offer.PRICING_MODEL_SINGLE);
        expect(bundle.product.extraParam).toBe('40');
        expect(bundle.badgeCode).toBe('ACH_1');
    });

    it('shows a chat style that comes with furniture as an add-on', () => {
        const withFurni = offer([product(ProductTypeEnum.FLOOR, 13, ''), product(ProductTypeEnum.CHAT_STYLE, 40, '40')]);

        expect(withFurni.isChatStyleOffer).toBe(false);
        expect(withFurni.pricingModel).toBe(Offer.PRICING_MODEL_SINGLE);
        expect(withFurni.product.productType).toBe(ProductTypeEnum.FLOOR);
        expect(withFurni.chatStyleId).toBe('40');
    });
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser