diff --git a/goofy-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button/postfach-mail-button.component.spec.ts b/goofy-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button/postfach-mail-button.component.spec.ts index 3b634b4437fe43ee170746bf0ae5a41335648a58..b55c1d860e8d2b65428dfcd45266fbfc1e08da89 100644 --- a/goofy-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button/postfach-mail-button.component.spec.ts +++ b/goofy-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button/postfach-mail-button.component.spec.ts @@ -28,6 +28,7 @@ import { createStateResource, EMPTY_STRING, HasLinkPipe } from '@goofy-client/te import { ButtonWithSpinnerComponent, IconButtonWithSpinnerComponent } from '@goofy-client/ui'; import { createCommandResource } from 'libs/command-shared/test/command'; import { createPostfachMailListResource } from 'libs/postfach-shared/test/postfach'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { PostfachMailButtonComponent } from './postfach-mail-button.component'; @@ -35,9 +36,9 @@ describe('PostfachMailButtonComponent', () => { let component: PostfachMailButtonComponent; let fixture: ComponentFixture<PostfachMailButtonComponent>; - const sendMailButtonWithText: string = '[data-test-id="create-mail-button-with-text"]'; - const sendMailButtonWithoutText: string = '[data-test-id="create-mail-button-without-text"]'; - const sendMailIconButton: string = '[data-test-id="send-mail-icon-button"]'; + const sendMailButtonWithText: string = getDataTestIdOf('create-mail-button-with-text'); + const sendMailButtonWithoutText: string = getDataTestIdOf('create-mail-button-without-text'); + const sendMailIconButton: string = getDataTestIdOf('send-mail-icon-button'); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -61,62 +62,67 @@ describe('PostfachMailButtonComponent', () => { expect(component).toBeTruthy(); }); - describe('send mail button with text', () => { - + describe('send mail button', () => { beforeEach(() => { component.showAsIconButton = false; - component.text = faker.word.noun(); - component.toolTip = EMPTY_STRING; - fixture.detectChanges(); }) - it('should be hidden', () => { - component.postfachMailListStateResource = createStateResource(createPostfachMailListResource()); + describe('with text', () => { - fixture.detectChanges(); - const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithText); + beforeEach(() => { + component.text = faker.word.noun(); + component.toolTip = EMPTY_STRING; + fixture.detectChanges(); + }) - expect(buttonElement).not.toBeInstanceOf(HTMLElement); - }); + it('should be hidden', () => { + component.postfachMailListStateResource = createStateResource(createPostfachMailListResource()); - it('should be visible', () => { - component.postfachMailListStateResource = createStateResource(createPostfachMailListResource([PostfachMailListLinkRel.SEND_POSTFACH_MAIL])); - component.pendingSendPostfachMailCommand = createStateResource(createCommandResource()); + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithText); - fixture.detectChanges(); - const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithText); + expect(buttonElement).not.toBeInstanceOf(HTMLElement); + }); - expect(buttonElement).toBeInstanceOf(HTMLElement); - }); - }) + it('should be visible', () => { + component.postfachMailListStateResource = createStateResource(createPostfachMailListResource([PostfachMailListLinkRel.SEND_POSTFACH_MAIL])); + component.pendingSendPostfachMailCommand = createStateResource(createCommandResource()); - describe('send mail button without text', () => { + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithText); - beforeEach(() => { - component.showAsIconButton = false; - component.text = EMPTY_STRING; - component.toolTip = faker.word.noun(); - fixture.detectChanges(); + expect(buttonElement).toBeInstanceOf(HTMLElement); + }); }) - it('should be hidden', () => { - component.postfachMailListStateResource = createStateResource(createPostfachMailListResource()); + describe('without text', () => { - fixture.detectChanges(); - const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithoutText); + beforeEach(() => { + component.text = EMPTY_STRING; + component.toolTip = faker.word.noun(); + fixture.detectChanges(); + }) - expect(buttonElement).not.toBeInstanceOf(HTMLElement); - }); + it('should be hidden', () => { + component.postfachMailListStateResource = createStateResource(createPostfachMailListResource()); - it('should be visible', () => { - component.postfachMailListStateResource = createStateResource(createPostfachMailListResource([PostfachMailListLinkRel.SEND_POSTFACH_MAIL])); - component.pendingSendPostfachMailCommand = createStateResource(createCommandResource()); + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithoutText); - fixture.detectChanges(); - const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithoutText); + expect(buttonElement).not.toBeInstanceOf(HTMLElement); + }); + + it('should be visible', () => { + component.postfachMailListStateResource = createStateResource(createPostfachMailListResource([PostfachMailListLinkRel.SEND_POSTFACH_MAIL])); + component.pendingSendPostfachMailCommand = createStateResource(createCommandResource()); + + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(sendMailButtonWithoutText); + + expect(buttonElement).toBeInstanceOf(HTMLElement); + }); + }) - expect(buttonElement).toBeInstanceOf(HTMLElement); - }); }) describe('send mail icon button', () => {