-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Romuald Caplier
committed
Aug 21, 2024
1 parent
0653674
commit 0a26381
Showing
11 changed files
with
363 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 22 additions & 25 deletions
47
libs/feature/editor/src/lib/components/contact-card/contact-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
<ng-container *ngIf="organization && contact"> | ||
<div class="flex flex-row gap-4 items-center"> | ||
<div | ||
class="flex flex-row border border-gray-200 rounded-xl p-4 gap-4 w-full" | ||
> | ||
<img | ||
[src]="organization.logoUrl" | ||
class="w-[56px] h-[56px] rounded-[4px]" | ||
/> | ||
<div class="flex flex-col w-full"> | ||
<div class="flex flex-row justify-between"> | ||
<span class="flex flex-wrap font-bold w-full" | ||
>{{ contact.firstName }} {{ contact.lastName }}</span | ||
> | ||
</div> | ||
<div>{{ contact.email }}</div> | ||
<div class="flex flex-row gap-4 items-center"> | ||
<div class="flex flex-row border border-gray-200 rounded-xl p-4 gap-4 w-full"> | ||
<gn-ui-thumbnail | ||
class="w-[56px] h-[56px] rounded-[4px]" | ||
[thumbnailUrl]="contact.organization.logoUrl?.href" | ||
[fit]="'contain'" | ||
></gn-ui-thumbnail> | ||
<div class="flex flex-col w-full"> | ||
<div class="flex flex-row justify-between"> | ||
<span class="flex flex-wrap font-bold w-full" | ||
>{{ contact.firstName }} {{ contact.lastName }}</span | ||
> | ||
</div> | ||
<div>{{ contact.email }}</div> | ||
</div> | ||
<gn-ui-button | ||
*ngIf="removable" | ||
data-test="removeContactButton" | ||
type="light" | ||
extraClass="w-[20px] h-[20px] flex items-center justify-center" | ||
(buttonClick)="removeContact(contact)" | ||
><span class="material-symbols-outlined"> close </span> | ||
</gn-ui-button> | ||
</div> | ||
</ng-container> | ||
<gn-ui-button | ||
*ngIf="removable" | ||
data-test="removeContactButton" | ||
type="light" | ||
extraClass="w-[20px] h-[20px] flex items-center justify-center" | ||
(buttonClick)="removeContact(contact)" | ||
><span class="material-symbols-outlined"> close </span> | ||
</gn-ui-button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,27 @@ import { | |
} from '@geonetwork-ui/common/domain/model/record' | ||
import { MatIconModule } from '@angular/material/icon' | ||
import { CommonModule } from '@angular/common' | ||
import { ButtonComponent } from '@geonetwork-ui/ui/inputs' | ||
import { | ||
AutocompleteComponent, | ||
ButtonComponent, | ||
} from '@geonetwork-ui/ui/inputs' | ||
import { ChangeDetectionStrategy } from '@angular/core' | ||
|
||
describe('ContactCardComponent', () => { | ||
let component: ContactCardComponent | ||
let fixture: ComponentFixture<ContactCardComponent> | ||
|
||
const mockContact: Individual = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
organization: { name: 'Org1' } as Organization, | ||
email: '[email protected]', | ||
role: 'admin', | ||
address: '', | ||
phone: '', | ||
position: '', | ||
} | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
|
@@ -20,57 +35,25 @@ describe('ContactCardComponent', () => { | |
ButtonComponent, | ||
ContactCardComponent, | ||
], | ||
}).compileComponents() | ||
}) | ||
.overrideComponent(AutocompleteComponent, { | ||
set: { changeDetection: ChangeDetectionStrategy.Default }, | ||
}) | ||
.compileComponents() | ||
}) | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ContactCardComponent) | ||
component = fixture.componentInstance | ||
component.contact = mockContact | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create the component', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('should have a defined contact input', () => { | ||
const mockContact: Individual = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
organization: { name: 'Org1' } as Organization, | ||
email: '[email protected]', | ||
role: 'admin', | ||
address: '', | ||
phone: '', | ||
position: '', | ||
} | ||
component.contact = mockContact | ||
fixture.detectChanges() | ||
expect(component.contact).toEqual(mockContact) | ||
}) | ||
|
||
it('should have a defined organization input', () => { | ||
const mockOrganization: Organization = { | ||
name: 'Org1', | ||
} | ||
component.organization = mockOrganization | ||
fixture.detectChanges() | ||
expect(component.organization).toEqual(mockOrganization) | ||
}) | ||
|
||
it('should emit contactRemoved event with the correct contact', () => { | ||
const mockContact: Individual = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
organization: { name: 'Org1' } as Organization, | ||
email: '[email protected]', | ||
role: 'admin', | ||
address: '', | ||
phone: '', | ||
position: '', | ||
} | ||
component.contact = mockContact | ||
|
||
const contactRemovedSpy = jest.spyOn(component.contactRemoved, 'emit') | ||
component.removeContact(mockContact) | ||
expect(contactRemovedSpy).toHaveBeenCalledWith(mockContact) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.