UNPKG

2.18 kBJavaScriptView Raw
1import { Product } from '../shared/product';
2import { VaProductDetailsComponent } from './product-details.component';
3describe('VaProductDetailsComponent', function () {
4 var component;
5 beforeEach(function () {
6 component = new VaProductDetailsComponent();
7 component.product = new Product({});
8 });
9 describe('getPrice', function () {
10 it('should get a formatted price based on currency, wholesale price and blling frequency', function () {
11 component.product.currency = 'USD';
12 component.product.wholesalePrice = 10000;
13 component.product.billingFrequency = 'monthly';
14 expect(component.price).toEqual({
15 currency: 'USD',
16 prices: [{
17 price: 10000,
18 frequency: 'monthly'
19 }]
20 });
21 });
22 it('should display Contact Sales for a null price', function () {
23 component.product.currency = 'USD';
24 component.product.wholesalePrice = null;
25 component.product.billingFrequency = 'monthly';
26 expect(component.price).toEqual({
27 currency: 'USD',
28 prices: []
29 });
30 });
31 it('should display Free for a 0 price', function () {
32 component.product.currency = 'USD';
33 component.product.wholesalePrice = 0;
34 component.product.billingFrequency = 'monthly';
35 expect(component.price).toEqual({
36 currency: 'USD',
37 prices: [{
38 price: 0,
39 frequency: 'monthly'
40 }]
41 });
42 });
43 });
44 describe('getActionLabel', function () {
45 it('should return enable if the product is archived', function () {
46 component.product.isArchived = true;
47 expect(component.getActionLabel()).toEqual('Enable');
48 });
49 it('should return enabled if the product is not archived', function () {
50 component.product.isArchived = false;
51 expect(component.getActionLabel()).toEqual('Enabled');
52 });
53 });
54});