Skip to content

Commit

Permalink
Update product-detail.component.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Sep 5, 2024
1 parent 96e69a3 commit 8b56aff
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ProductDetailComponent } from './product-detail.component';
import { ProductModuleContent } from '../../../shared/models/product-module-content.model';
import { RoutingQueryParamService } from '../../../shared/services/routing.query.param.service';
import { MockProductService } from '../../../shared/mocks/mock-services';
import { ProductDetailActionType } from '../../../shared/enums/product-detail-action-type';
const products = MOCK_PRODUCTS._embedded.products;
declare const viewport: Viewport;

Expand Down Expand Up @@ -334,4 +335,34 @@ describe('ProductDetailComponent', () => {
component.handleProductContentVersion();
expect(component.selectedVersion).toEqual('Version 10.0.11');
});

it('should set ProductDetailActionType to DESIGNER_ENV when isDesignerEnv returns true', () => {
routingQueryParamService.isDesignerEnv.and.returnValue(true);

component.updateProductDetailActionType({} as any); // Pass an empty object as ProductDetail

expect(component.productDetailActionType()).toBe(
ProductDetailActionType.DESIGNER_ENV
);
});

it('should set ProductDetailActionType to CUSTOM_SOLUTION when productDetail.sourceUrl is undefined', () => {
routingQueryParamService.isDesignerEnv.and.returnValue(false);

component.updateProductDetailActionType({ sourceUrl: undefined } as any);

expect(component.productDetailActionType()).toBe(
ProductDetailActionType.CUSTOM_SOLUTION
);
});

it('should set ProductDetailActionType to STANDARD when productDetail.sourceUrl is defined', () => {
routingQueryParamService.isDesignerEnv.and.returnValue(false);

component.updateProductDetailActionType({ sourceUrl: 'some-url' } as any);

expect(component.productDetailActionType()).toBe(
ProductDetailActionType.STANDARD
);
});
});

0 comments on commit 8b56aff

Please sign in to comment.