Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@
Save Draft
</button>
<button
*ngIf="selectedProfile?.status !== ProfileStatus.EXPIRED"
mat-button
class="discard-button"
[disabled]="profileForm.pristine"
(click)="onDiscardClick()">
Discard
</button>
<button
*ngIf="selectedProfile?.status === ProfileStatus.EXPIRED"
mat-button
class="discard-button"
(click)="onDiscardClick()">
Close
</button>
</div>

<ng-template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ describe('ProfileFormComponent', () => {
fixture.detectChanges();
});

it('should has Discard text', () => {
const discardButton = compiled.querySelector(
'.discard-button'
) as HTMLButtonElement;

expect(discardButton.textContent?.trim()).toEqual('Discard');
});

it('should be enabled when form is filled', () => {
const discardButton = compiled.querySelector(
'.discard-button'
Expand Down Expand Up @@ -433,6 +441,34 @@ describe('ProfileFormComponent', () => {
).toBeTrue();
});
});

describe('Close button', () => {
it('should has Discard text', () => {
const discardButton = compiled.querySelector(
'.discard-button'
) as HTMLButtonElement;

expect(discardButton.textContent?.trim()).toEqual('Close');
});

it('should be enabled', () => {
const discardButton = compiled.querySelector(
'.discard-button'
) as HTMLButtonElement;

expect(discardButton.disabled).toBeFalse();
});

it('should emit discard', () => {
const emitSpy = spyOn(component.discard, 'emit');
const discardButton = compiled.querySelector(
'.discard-button'
) as HTMLButtonElement;
discardButton.click();

expect(emitSpy).toHaveBeenCalled();
});
});
});
});

Expand Down