Skip to content
Snippets Groups Projects
Commit a76a757d authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6300 Add function to get dataTestId

parent 8d066bc3
Branches
Tags
No related merge requests found
...@@ -6,9 +6,9 @@ import { ...@@ -6,9 +6,9 @@ import {
notExistsAsHtmlElement, notExistsAsHtmlElement,
} from '@alfa-client/test-utils'; } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { 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 { MockComponent } from 'ng-mocks';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container.component'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container.component';
...@@ -18,7 +18,7 @@ describe('CollaborationInVorgangContainerComponent', () => { ...@@ -18,7 +18,7 @@ describe('CollaborationInVorgangContainerComponent', () => {
let component: CollaborationInVorgangContainerComponent; let component: CollaborationInVorgangContainerComponent;
let fixture: ComponentFixture<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 collaborationRequestContainer: string = getDataTestIdOf('collaboration-request-container');
const service: Mock<CollaborationService> = { const service: Mock<CollaborationService> = {
...@@ -28,9 +28,9 @@ describe('CollaborationInVorgangContainerComponent', () => { ...@@ -28,9 +28,9 @@ describe('CollaborationInVorgangContainerComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [ButtonComponent, SaveIconComponent],
declarations: [ declarations: [
CollaborationInVorgangContainerComponent, CollaborationInVorgangContainerComponent,
MockComponent(ButtonComponent),
MockComponent(CollaborationRequestContainerComponent), MockComponent(CollaborationRequestContainerComponent),
MockComponent(CollaborationIconComponent), MockComponent(CollaborationIconComponent),
], ],
...@@ -74,7 +74,7 @@ describe('CollaborationInVorgangContainerComponent', () => { ...@@ -74,7 +74,7 @@ describe('CollaborationInVorgangContainerComponent', () => {
it('should call service on click', () => { it('should call service on click', () => {
fixture.detectChanges(); fixture.detectChanges();
dispatchEventFromFixture(fixture, anfrageErstellenButton, 'click'); dispatchEventFromFixture(fixture, anfrageErstellenButton, 'clickEmitter');
expect(service.showRequestForm).toHaveBeenCalled(); expect(service.showRequestForm).toHaveBeenCalled();
}); });
......
...@@ -2,7 +2,7 @@ import { dispatchEventFromFixture } from '@alfa-client/test-utils'; ...@@ -2,7 +2,7 @@ import { dispatchEventFromFixture } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ButtonComponent, CloseIconComponent } from '@ods/system'; import { ButtonComponent, CloseIconComponent } from '@ods/system';
import { SearchIconComponent } from 'libs/design-system/src/lib/icons/search-icon/search-icon.component'; 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 { MockComponent } from 'ng-mocks';
import { CollaborationRequestContainerComponent } from './collaboration-request-container.component'; import { CollaborationRequestContainerComponent } from './collaboration-request-container.component';
import { CollaborationRequestFormComponent } from './collaboration-request-form/collaboration-request-form.component'; import { CollaborationRequestFormComponent } from './collaboration-request-form/collaboration-request-form.component';
...@@ -11,13 +11,13 @@ describe('CollaborationRequestContainerComponent', () => { ...@@ -11,13 +11,13 @@ describe('CollaborationRequestContainerComponent', () => {
let component: CollaborationRequestContainerComponent; let component: CollaborationRequestContainerComponent;
let fixture: ComponentFixture<CollaborationRequestContainerComponent>; let fixture: ComponentFixture<CollaborationRequestContainerComponent>;
const cancelButton: string = getDataTestIdOf('collaboration-request-cancel-button'); const cancelButton: string = getDataTestIdAttributeOf('collaboration-request-cancel-button');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [ButtonComponent],
declarations: [ declarations: [
CollaborationRequestContainerComponent, CollaborationRequestContainerComponent,
MockComponent(ButtonComponent),
MockComponent(SearchIconComponent), MockComponent(SearchIconComponent),
MockComponent(CloseIconComponent), MockComponent(CloseIconComponent),
MockComponent(CollaborationRequestFormComponent), MockComponent(CollaborationRequestFormComponent),
...@@ -37,7 +37,7 @@ describe('CollaborationRequestContainerComponent', () => { ...@@ -37,7 +37,7 @@ describe('CollaborationRequestContainerComponent', () => {
it('should emit hideRequestForm', () => { it('should emit hideRequestForm', () => {
const emitSpy = (component.hideRequestForm.emit = jest.fn()); const emitSpy = (component.hideRequestForm.emit = jest.fn());
dispatchEventFromFixture(fixture, cancelButton, 'click'); dispatchEventFromFixture(fixture, cancelButton, 'clickEmitter');
expect(emitSpy).toHaveBeenCalled(); expect(emitSpy).toHaveBeenCalled();
}); });
......
...@@ -28,3 +28,7 @@ export function getDataTestClassOf(value: string): string { ...@@ -28,3 +28,7 @@ export function getDataTestClassOf(value: string): string {
export function getDataTestIdOf(value: string): string { export function getDataTestIdOf(value: string): string {
return `[data-test-id="${value}"]`; return `[data-test-id="${value}"]`;
} }
export function getDataTestIdAttributeOf(value: string): string {
return `[dataTestId="${value}"]`;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment