UNPKG

@vendasta/store

Version:

Components and data for Store

59 lines (58 loc) 3.8 kB
import { VaPackageDetailsComponent } from './package-details.component'; import { Package } from './package'; import { Product } from '../shared'; import { Addon } from '@vendasta/core/marketplace-apps'; describe('VaPackageDetailsComponent', function () { var combinedItemsList; var pkg; beforeEach(function () { pkg = new Package(); combinedItemsList = []; }); describe('getDisplayTagline', function () { it('should display tagline if it exists on the package', function () { pkg.tagline = 'jiggles co.'; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual('jiggles co.'); }); it('should display tagline if it exists on the package even if single product and single product tagline', function () { pkg.tagline = 'jiggles co.'; combinedItemsList = [Product.fromApi({ tagline: 'Best in the West' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual('jiggles co.'); }); it('should display tagline if it exists on the package even if single addon and single addon tagline', function () { pkg.tagline = 'jiggles co.'; combinedItemsList = [Addon.fromApi({ tagline: 'Best in the East' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual('jiggles co.'); }); it('should display product tagline if no package tagline and only one product and no Addons', function () { combinedItemsList = [Product.fromApi({ tagline: 'Best in the West' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual('Best in the West'); }); it('should display addon tagline if no package tagline and only one addon and no Products', function () { combinedItemsList = [Addon.fromApi({ tagline: 'Best in the East' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual('Best in the East'); }); it('should display no tagline if no package tagline and more than one product', function () { combinedItemsList = [Product.fromApi({ tagline: 'Best in the West' }), Product.fromApi({ tagline: 'Best in the North' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual(''); }); it('should display no tagline if no package tagline and more than one addon', function () { combinedItemsList = [Addon.fromApi({ tagline: 'Best in the East' }), Addon.fromApi({ tagline: 'Best in the South' })]; expect(VaPackageDetailsComponent.getDisplayTagline(pkg, combinedItemsList)).toEqual(''); }); }); describe('getProductNameForSingleAddon', function () { it('should display the product name for a single addon package', function () { combinedItemsList = [Addon.fromApi({ productName: 'Best in the East' })]; expect(VaPackageDetailsComponent.getProductNameForSingleAddon(combinedItemsList)).toEqual('Best in the East'); }); it('should not display the product name for a single product package', function () { combinedItemsList = [Product.fromApi({})]; expect(VaPackageDetailsComponent.getProductNameForSingleAddon(combinedItemsList)).toEqual(undefined); }); it('should not display the product name for a multi addon package', function () { combinedItemsList = [Addon.fromApi({ productName: 'Best in the East' }), Addon.fromApi({ productName: 'Best in the West' })]; expect(VaPackageDetailsComponent.getProductNameForSingleAddon(combinedItemsList)).toEqual(undefined); }); }); });