diff --git a/src/app/public/components/public-archive/public-archive.component.html b/src/app/public/components/public-archive/public-archive.component.html index b7d369301..482f8cf36 100644 --- a/src/app/public/components/public-archive/public-archive.component.html +++ b/src/app/public/components/public-archive/public-archive.component.html @@ -26,8 +26,20 @@ }" >
-
The {{ this.archive.fullName }} Archive
-
+
+ The {{ this.archive.fullName }} Archive + +
+
-
- {{ this.profileItems.blurb[0].string1 }} +
+
+ {{ this.profileItems.blurb[0].string1 }} +
+ + + {{ showShortText ? ' See More' : ' See Less' }} +
- - - {{ showShortText ? ' See More' : ' See Less' }} -
@@ -122,6 +136,7 @@ class="btn btn-link" [routerLink]="['/p', 'archive', archive.archiveNbr]" [hidden]="!(isViewingProfile$ | async)" + (click)="showProfileInformation = false" > View Public Archive View Public Profile { -// let component: PublicArchiveComponent; -// let fixture: ComponentFixture; - -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ PublicArchiveComponent ] -// }) -// .compileComponents(); -// })); - -// beforeEach(() => { -// fixture = TestBed.createComponent(PublicArchiveComponent); -// component = fixture.componentInstance; -// fixture.detectChanges(); -// }); - -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); -// }); +/* @format */ +import { waitForAsync } from '@angular/core/testing'; +import { PublicModule } from '@public/public.module'; +import { Shallow } from 'shallow-render'; +import { of } from 'rxjs'; +import { PublicProfileService } from '@public/services/public-profile/public-profile.service'; +import { PublicArchiveComponent } from './public-archive.component'; + +const publicProfileServiceMock = { + publicRoot$: () => of({}), + archive$: () => of({}), + profileItemsDictionary$: () => of({}), +}; + +describe('PublicArchiveComponent', () => { + let shallow: Shallow; + + beforeEach(waitForAsync(() => { + shallow = new Shallow(PublicArchiveComponent, PublicModule).provideMock({ + provide: PublicProfileService, + useValue: publicProfileServiceMock, + }); + })); + + it('should create', async () => { + const { instance } = await shallow.render(); + + expect(instance).toBeTruthy(); + }); + + it('should have the information hidden as default', async () => { + const { instance } = await shallow.render(); + + expect(instance.showProfileInformation).toBe(false); + }); + + it('should have the information shown when the button is clicked', async () => { + const { instance, find } = await shallow.render(); + const icon = find('.icon-expand'); + icon.nativeElement.click(); + + expect(instance.showProfileInformation).toBe(true); + }); + + it('should give the correct classes when expanding the information', async () => { + const { find, fixture, instance } = await shallow.render(); + const icon = find('.icon-expand'); + icon.nativeElement.click(); + + fixture.detectChanges(); + + expect(find('.archive-description').classes).toEqual({ + 'archive-description': true, + 'archive-description-show': true, + }); + }); +}); diff --git a/src/app/public/components/public-archive/public-archive.component.ts b/src/app/public/components/public-archive/public-archive.component.ts index a077740b4..127909cbf 100644 --- a/src/app/public/components/public-archive/public-archive.component.ts +++ b/src/app/public/components/public-archive/public-archive.component.ts @@ -31,6 +31,7 @@ export class PublicArchiveComponent implements OnInit, OnDestroy { shortText = ''; emails: string[] = []; websites: string[] = []; + showProfileInformation: boolean = false; waiting = true; @@ -125,4 +126,8 @@ export class PublicArchiveComponent implements OnInit, OnDestroy { toggleShowFullText(): void { this.showShortText = !this.showShortText; } + + toggleProfileInformation(): void { + this.showProfileInformation = !this.showProfileInformation; + } } diff --git a/src/app/public/public.module.ts b/src/app/public/public.module.ts index e7ea22203..6ef05a5d1 100644 --- a/src/app/public/public.module.ts +++ b/src/app/public/public.module.ts @@ -1,3 +1,4 @@ +/* @format */ import { NgModule, Optional, ComponentFactoryResolver } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; @@ -5,7 +6,12 @@ import { FaIconLibrary, FontAwesomeModule, } from '@fortawesome/angular-fontawesome'; -import { faSearch, faTimesCircle } from '@fortawesome/free-solid-svg-icons'; +import { + faSearch, + faTimesCircle, + faChevronDown, + faChevronUp, +} from '@fortawesome/free-solid-svg-icons'; import { DataService } from '@shared/services/data/data.service'; import { FolderViewService } from '@shared/services/folder-view/folder-view.service'; import { FileBrowserModule } from '@fileBrowser/file-browser.module'; @@ -53,7 +59,7 @@ import { PublicSearchResultsComponent } from './components/public-search-results }) export class PublicModule { constructor(folderView: FolderViewService, private library: FaIconLibrary) { - this.library.addIcons(faSearch, faTimesCircle); + this.library.addIcons(faSearch, faTimesCircle, faChevronDown, faChevronUp); folderView.setFolderView(FolderView.Grid, true); } }