Skip to content

Commit

Permalink
enhance FE unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
quanpham-axonivy committed Dec 25, 2024
1 parent f4042d8 commit c01a202
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h3 [lang]="languageService.selectedLanguage()" class="text-secondary">
[selectedItem]="getSelectedTabLabel() | translate"
buttonClass="form-select flex-grow-1 text-start content-tab-dropdown"
(itemSelected)="
onTabChange($event.value)
setActiveTab($event.value)
"></app-common-dropdown>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ export class ReleasePreviewComponent {
this.handlePreviewPage();
}

setActiveTab(tab: string): void {
this.activeTab = tab;
}

onTabChange(event: string) {
this.setActiveTab(event);
setActiveTab(event: string): void {
this.activeTab = event;
}

handlePreviewPage(): void {
Expand Down Expand Up @@ -108,32 +104,18 @@ export class ReleasePreviewComponent {
getContent(value: string): boolean {
const content = this.readmeContent();

if (!content || Object.keys(content).length === 0) {
return false;
}

const conditions: { [key: string]: boolean } = {
description:
content.description !== null &&
CommonUtils.isContentDisplayedBasedOnLanguage(
content.description,
this.languageService.selectedLanguage()
),
demo:
content.demo !== null &&
CommonUtils.isContentDisplayedBasedOnLanguage(
content.demo,
this.languageService.selectedLanguage()
),
setup:
content.setup !== null &&
if (content && content[value as keyof ReleasePreviewData]) {
const tabContent = content[value as keyof ReleasePreviewData];
return (
tabContent != null &&
Object.keys(tabContent).length > 0 &&
CommonUtils.isContentDisplayedBasedOnLanguage(
content.setup,
tabContent,
this.languageService.selectedLanguage()
)
};

return conditions[value] ?? false;
);
}
return false;
}

getSelectedTabLabel() {
Expand Down

0 comments on commit c01a202

Please sign in to comment.