UNPKG

@vendasta/store

Version:

Components and data for Store

55 lines (54 loc) 2.18 kB
import { Product } from '../shared/product'; import { VaProductDetailsComponent } from './product-details.component'; describe('VaProductDetailsComponent', function () { var component; beforeEach(function () { component = new VaProductDetailsComponent(); component.product = new Product({}); }); describe('getPrice', function () { it('should get a formatted price based on currency, wholesale price and blling frequency', function () { component.product.currency = 'USD'; component.product.wholesalePrice = 10000; component.product.billingFrequency = 'monthly'; expect(component.price).toEqual({ currency: 'USD', prices: [{ price: 10000, frequency: 'monthly' }] }); }); it('should display Contact Sales for a null price', function () { component.product.currency = 'USD'; component.product.wholesalePrice = null; component.product.billingFrequency = 'monthly'; expect(component.price).toEqual({ currency: 'USD', prices: [] }); }); it('should display Free for a 0 price', function () { component.product.currency = 'USD'; component.product.wholesalePrice = 0; component.product.billingFrequency = 'monthly'; expect(component.price).toEqual({ currency: 'USD', prices: [{ price: 0, frequency: 'monthly' }] }); }); }); describe('getActionLabel', function () { it('should return enable if the product is archived', function () { component.product.isArchived = true; expect(component.getActionLabel()).toEqual('Enable'); }); it('should return enabled if the product is not archived', function () { component.product.isArchived = false; expect(component.getActionLabel()).toEqual('Enabled'); }); }); });