From a76a757d10dff8be0fa69cb86d4cfd1ebd6b8c08 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 12 Aug 2024 15:20:38 +0200 Subject: [PATCH] OZG-6300 Add function to get dataTestId --- ...ollaboration-in-vorgang-container.component.spec.ts | 10 +++++----- .../collaboration-request-container.component.spec.ts | 8 ++++---- alfa-client/libs/tech-shared/test/data-test.ts | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts index 7faaca7531..d5814a551c 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts @@ -6,9 +6,9 @@ import { notExistsAsHtmlElement, } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ButtonComponent, CollaborationIconComponent, SaveIconComponent } from '@ods/system'; +import { ButtonComponent, CollaborationIconComponent } from '@ods/system'; import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; -import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { getDataTestIdAttributeOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container.component'; @@ -18,7 +18,7 @@ describe('CollaborationInVorgangContainerComponent', () => { let component: CollaborationInVorgangContainerComponent; let fixture: ComponentFixture<CollaborationInVorgangContainerComponent>; - const anfrageErstellenButton: string = getDataTestIdOf('anfrage-erstellen-button'); + const anfrageErstellenButton: string = getDataTestIdAttributeOf('anfrage-erstellen-button'); const collaborationRequestContainer: string = getDataTestIdOf('collaboration-request-container'); const service: Mock<CollaborationService> = { @@ -28,9 +28,9 @@ describe('CollaborationInVorgangContainerComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ButtonComponent, SaveIconComponent], declarations: [ CollaborationInVorgangContainerComponent, + MockComponent(ButtonComponent), MockComponent(CollaborationRequestContainerComponent), MockComponent(CollaborationIconComponent), ], @@ -74,7 +74,7 @@ describe('CollaborationInVorgangContainerComponent', () => { it('should call service on click', () => { fixture.detectChanges(); - dispatchEventFromFixture(fixture, anfrageErstellenButton, 'click'); + dispatchEventFromFixture(fixture, anfrageErstellenButton, 'clickEmitter'); expect(service.showRequestForm).toHaveBeenCalled(); }); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-container/collaboration-request-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-container/collaboration-request-container.component.spec.ts index 074ae43ab3..9cac3e35dd 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-container/collaboration-request-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-container/collaboration-request-container.component.spec.ts @@ -2,7 +2,7 @@ import { dispatchEventFromFixture } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ButtonComponent, CloseIconComponent } from '@ods/system'; import { SearchIconComponent } from 'libs/design-system/src/lib/icons/search-icon/search-icon.component'; -import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { getDataTestIdAttributeOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { CollaborationRequestContainerComponent } from './collaboration-request-container.component'; import { CollaborationRequestFormComponent } from './collaboration-request-form/collaboration-request-form.component'; @@ -11,13 +11,13 @@ describe('CollaborationRequestContainerComponent', () => { let component: CollaborationRequestContainerComponent; let fixture: ComponentFixture<CollaborationRequestContainerComponent>; - const cancelButton: string = getDataTestIdOf('collaboration-request-cancel-button'); + const cancelButton: string = getDataTestIdAttributeOf('collaboration-request-cancel-button'); beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ButtonComponent], declarations: [ CollaborationRequestContainerComponent, + MockComponent(ButtonComponent), MockComponent(SearchIconComponent), MockComponent(CloseIconComponent), MockComponent(CollaborationRequestFormComponent), @@ -37,7 +37,7 @@ describe('CollaborationRequestContainerComponent', () => { it('should emit hideRequestForm', () => { const emitSpy = (component.hideRequestForm.emit = jest.fn()); - dispatchEventFromFixture(fixture, cancelButton, 'click'); + dispatchEventFromFixture(fixture, cancelButton, 'clickEmitter'); expect(emitSpy).toHaveBeenCalled(); }); diff --git a/alfa-client/libs/tech-shared/test/data-test.ts b/alfa-client/libs/tech-shared/test/data-test.ts index d0c53e43d6..4b4b9cc2b8 100644 --- a/alfa-client/libs/tech-shared/test/data-test.ts +++ b/alfa-client/libs/tech-shared/test/data-test.ts @@ -28,3 +28,7 @@ export function getDataTestClassOf(value: string): string { export function getDataTestIdOf(value: string): string { return `[data-test-id="${value}"]`; } + +export function getDataTestIdAttributeOf(value: string): string { + return `[dataTestId="${value}"]`; +} -- GitLab