Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Dec 17, 2024
1 parent 9c03e41 commit ec32a56
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 40 deletions.
5 changes: 1 addition & 4 deletions marketplace-ui/src/app/core/interceptors/api.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { environment } from '../../../environments/environment';
import { inject } from '@angular/core';
import { catchError, EMPTY, finalize } from 'rxjs';
import { Router } from '@angular/router';
import {
ERROR_CODES,
ERROR_PAGE_PATH
} from '../../shared/constants/common.constant';
import { ERROR_CODES, ERROR_PAGE_PATH } from '../../shared/constants/common.constant';
import { LoadingService } from '../services/loading/loading.service';

export const REQUEST_BY = 'X-Requested-By';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,20 @@ describe('ProductFeedbackService', () => {

it('should initialize feedbacks', () => {
const mockResponse = {
_embedded: {
feedbacks: [{ content: 'Great product!', rating: 5, productId: '123' }]
},
_embedded: { feedbacks: [{ content: 'Great product!', rating: 5, productId: '123' }] },
page: { totalPages: 2, totalElements: 5 }
};

productDetailService.productId.and.returnValue('123');

service.fetchFeedbacks();
const req = httpMock.expectOne(
'api/feedback/product/123?page=0&size=8&sort=newest'
);
const req = httpMock.expectOne( 'api/feedback/product/123?page=0&size=8&sort=newest' );
expect(req.request.method).toBe('GET');
req.flush(mockResponse);

expect(service.totalPages()).toBe(2);
expect(service.totalElements()).toBe(5);
expect(service.feedbacks()).toEqual([
{ content: 'Great product!', rating: 5, productId: '123' }
]);
expect(service.feedbacks()).toEqual([{ content: 'Great product!', rating: 5, productId: '123' }]);
});

it('should load more feedbacks', () => {
Expand All @@ -94,24 +88,14 @@ describe('ProductFeedbackService', () => {

productDetailService.productId.and.returnValue('123');
service.fetchFeedbacks();
const initReq = httpMock.expectOne(
'api/feedback/product/123?page=0&size=8&sort=newest'
);
initReq.flush({
_embedded: { feedbacks: initialFeedback },
page: { totalPages: 2, totalElements: 5 }
});
const initReq = httpMock.expectOne( 'api/feedback/product/123?page=0&size=8&sort=newest' );
initReq.flush({ _embedded: { feedbacks: initialFeedback }, page: { totalPages: 2, totalElements: 5 } });

service.loadMoreFeedbacks();
const loadMoreReq = httpMock.expectOne(
'api/feedback/product/123?page=1&size=8&sort=newest'
);
const loadMoreReq = httpMock.expectOne( 'api/feedback/product/123?page=1&size=8&sort=newest' );
loadMoreReq.flush({ _embedded: { feedbacks: additionalFeedback } });

expect(service.feedbacks()).toEqual([
...initialFeedback,
...additionalFeedback
]);
expect(service.feedbacks()).toEqual([...initialFeedback, ...additionalFeedback]);
});

it('should change sort and fetch feedbacks', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export class ProductFeedbackService {
return this.http
.get<FeedbackApiResponse>(requestURL, {
params: requestParams,
context: new HttpContext()
.set(SkipLoading, true)
.set(ForwardingError, true)
context: new HttpContext().set(SkipLoading, true).set(ForwardingError, true)
})
.pipe(
tap(response => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export class ProductDetailInformationTabComponent implements OnChanges {
ngOnChanges(changes: SimpleChanges): void {
let version = '';
const changedSelectedVersion = changes[SELECTED_VERSION];
if (
changedSelectedVersion &&
if ( changedSelectedVersion &&
changedSelectedVersion.currentValue ===
changedSelectedVersion.previousValue
) {
Expand Down Expand Up @@ -98,8 +97,7 @@ export class ProductDetailInformationTabComponent implements OnChanges {
// To ensure the function always returns a boolean, you can explicitly coerce the result into a boolean using the !! operator or default it to false
// Adding !! in case of changedProduct is undefined, it will return false instead of returning undefined
isProductChanged(changedProduct: SimpleChange) {
return !!(
changedProduct?.previousValue &&
return !!( changedProduct?.previousValue &&
Object.keys(changedProduct.previousValue).length > 0 &&
changedProduct.currentValue !== changedProduct.previousValue
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,12 @@
(click)="onUpdateInstallationCountForDesigner()" onClick="function installInDesigner(event) {
const selectedItemElement = document.querySelector('.install-designer-dropdown');
if (selectedItemElement) {
<<<<<<< HEAD
const metaDataJsonUrl = selectedItemElement.getAttribute('metaDataJsonUrl');
install(metaDataJsonUrl);
=======
const metaDataJsonUrl = selectedItemElement.getAttribute('metaDataJsonUrl');
try {
install(metaDataJsonUrl);
} catch (error) {
event.stopImmediatePropagation();
}
>>>>>>> develop
}
}
installInDesigner(event);" [ngClass]="themeService.isDarkMode() ? 'btn-light' : 'btn-primary'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { ProductDetailActionType } from '../../../../shared/enums/product-detail
import { MATOMO_TRACKING_ENVIRONMENT } from '../../../../shared/constants/matomo.constant';

class MockElementRef implements ElementRef {
nativeElement = { contains: jasmine.createSpy('contains') };
nativeElement = {
contains: jasmine.createSpy('contains')
};
}

describe('ProductDetailVersionActionComponent', () => {
Expand Down

0 comments on commit ec32a56

Please sign in to comment.