From 91d215a81ee3f9d660c0082ad4ce91bfd9d75be7 Mon Sep 17 00:00:00 2001 From: Vikram Raj Date: Mon, 6 Aug 2018 17:39:30 +0530 Subject: [PATCH] fix(mission-runtime-creatapp): hide more option if description have less then 55 character --- ...sion-runtime-createapp-step.component.html | 8 +-- ...n-runtime-createapp-step.component.spec.ts | 62 +++++++++++++++---- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.html b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.html index 9db9a965..530bc2ee 100644 --- a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.html +++ b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.html @@ -105,13 +105,13 @@

{{mission.name}}
- + {{mission.description | truncate: 55}} {{mission.description}} - + {{(mission.showMore) ? 'Less' : 'More'}} @@ -222,13 +222,13 @@

- + {{runtime.description | truncate: 55}} {{runtime.description}} - + {{(runtime.showMore) ? 'Less' : 'More'}} diff --git a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts index ce5b01f5..2a7c21a3 100644 --- a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts +++ b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts @@ -20,7 +20,9 @@ import { createMission, createRuntime } from '../../service/mission-runtime.service.spec'; -import { BroadcasterTestProvider } from '../targetenvironment-createapp-step/target-environment-createapp-step.component.spec'; +import { + BroadcasterTestProvider +} from '../targetenvironment-createapp-step/target-environment-createapp-step.component.spec'; import { Observable } from 'rxjs/Observable'; import { Catalog } from '../../model/catalog.model'; @@ -224,19 +226,43 @@ describe('MissionRuntimeStepComponent', () => { } })); - it('should show "Less" if the showMore is true - Missions', () => { + it('should show "Less" if the showMore is true and description length is more then 55 characters - Missions', () => { component.missions[0]['showMore'] = true; fixture.detectChanges(); let missionsSection = element.querySelectorAll('.card-pf-body')[0]; - let showMore = missionsSection.querySelector('.description-more').children[0]; - expect(showMore.innerText.trim()).toBe('Less'); + let missionItems = missionsSection.querySelectorAll('.list-group-item-text'); + let descElement1 = missionsSection.querySelectorAll('.list-group-item-text .description')[0]; + let description1 = descElement1.innerText.trim(); + let index1 = description1.indexOf('...'); + if (index1 > -1) { + let showMore = missionsSection.querySelector('.description-more').children[0]; + expect(showMore.innerText.trim()).toBe('Less'); + } else { + let showMoreElement = missionItems[0].querySelector('.description-more'); + expect(showMoreElement).toEqual(null); + } + let descElement2 = missionItems[1].querySelector('.description'); + let description2 = descElement2.innerText.trim(); + let index2 = description2.indexOf('...'); + if (index2 > -1) { + let showMore = missionsSection.querySelector('.description-more').children[0]; + expect(showMore.innerText.trim()).toBe('Less'); + } else { + let showMoreElement = missionItems[1].querySelector('.description-more'); + expect(showMoreElement).toEqual(null); + } }); - it('should show "More" if the showMore is false - Missions', () => { + it('should show "More" if the showMore is false and description length is more that 55 characters - Missions', () => { fixture.detectChanges(); let missionsSection = element.querySelectorAll('.card-pf-body')[0]; - let showMore = missionsSection.querySelector('.description-more').children[0]; - expect(showMore.innerText.trim()).toBe('More'); + let descElement = missionsSection.querySelectorAll('.list-group-item-text .description')[0]; + let description = descElement.innerText.trim(); + let index = description.indexOf('...'); + if (index > -1) { + let showMore = missionsSection.querySelector('.description-more').children[0]; + expect(showMore.innerText.trim()).toBe('More'); + } }); it('should disable the runtimes, on click of mission, which aren\'t applicable', fakeAsync(() => { @@ -338,19 +364,29 @@ describe('MissionRuntimeStepComponent', () => { } }); - it('should show "Less" if the showMore is true - Runtimes', () => { + it('should show "Less" if the showMore is true and description length is more that 55 characters - Runtimes', () => { component.runtimes[0].showMore = true; fixture.detectChanges(); let runtimesSection = element.querySelectorAll('.card-pf-body')[1]; - let showMore = runtimesSection.querySelector('.description-more').children[0]; - expect(showMore.innerText.trim()).toBe('Less'); + let descElement = runtimesSection.querySelectorAll('.list-group-item-text .description')[0]; + let description = descElement.innerText.trim(); + let index = description.indexOf('...'); + if (index > -1) { + let showMore = runtimesSection.querySelector('.description-more').children[0]; + expect(showMore.innerText.trim()).toBe('Less'); + } }); - it('should show "More" if the showMore is false - Runtimes', () => { + it('should show "More" if the showMore is false and description length is more that 55 characters - Runtimes', () => { fixture.detectChanges(); let runtimesSection = element.querySelectorAll('.card-pf-body')[1]; - let showMore = runtimesSection.querySelector('.description-more').children[0]; - expect(showMore.innerText.trim()).toBe('More'); + let descElement = runtimesSection.querySelectorAll('.list-group-item-text .description')[0]; + let description = descElement.innerText.trim(); + let index = description.indexOf('...'); + if (index > -1) { + let showMore = runtimesSection.querySelector('.description-more').children[0]; + expect(showMore.innerText.trim()).toBe('More'); + } }); it('should complete step when booster is selected', fakeAsync(() => {