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

OZG-6908 remove generic error message from button

parent 0ccaed8d
No related branches found
No related tags found
No related merge requests found
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { import { createCommandResource } from 'libs/command-shared/test/command';
createCommandErrorStateResource,
createCommandResource,
} from 'libs/command-shared/test/command';
import { createApiError } from 'libs/tech-shared/test/error';
import { ButtonWithSpinnerComponent } from './button-with-spinner.component'; import { ButtonWithSpinnerComponent } from './button-with-spinner.component';
import * as ResourceUtils from 'libs/tech-shared/src/lib/resource/resource.util'; import * as ResourceUtils from 'libs/tech-shared/src/lib/resource/resource.util';
...@@ -83,30 +79,4 @@ describe('ButtonWithSpinnerComponent', () => { ...@@ -83,30 +79,4 @@ describe('ButtonWithSpinnerComponent', () => {
expect(isLoading).toBeTruthy(); expect(isLoading).toBeTruthy();
}); });
}); });
describe('isError', () => {
it('should return false if error is not set', () => {
component.stateResource.error = null;
const isError: boolean = component.isError;
expect(isError).toBeFalsy();
});
it('should return false if error is set and error is ApiError', () => {
component.stateResource.error = createApiError();
const isError: boolean = component.isError;
expect(isError).toBeFalsy();
});
it('should return true if error is set and error is not ApiError', () => {
component.stateResource = createCommandErrorStateResource();
const isError: boolean = component.isError;
expect(isError).toBeTruthy();
});
});
}); });
...@@ -13,21 +13,14 @@ type ButtonVariants = VariantProps<typeof buttonVariants>; ...@@ -13,21 +13,14 @@ type ButtonVariants = VariantProps<typeof buttonVariants>;
standalone: true, standalone: true,
imports: [CommonModule, ButtonComponent, ErrorMessageComponent], imports: [CommonModule, ButtonComponent, ErrorMessageComponent],
styles: [':host {@apply flex flex-col w-fit}'], styles: [':host {@apply flex flex-col w-fit}'],
template: ` <ods-error-message template: `<ods-button
*ngIf="isError"
text="Ein Fehler ist aufgetreten."
subText="Versuchen Sie es noch einmal."
>
</ods-error-message>
<ods-button
[text]="text" [text]="text"
[variant]="variant" [variant]="variant"
[size]="size" [size]="size"
[dataTestId]="dataTestId" [dataTestId]="dataTestId"
[isLoading]="isLoading" [isLoading]="isLoading"
(click)="clickEmitter.emit()" (click)="clickEmitter.emit()"
> />`,
</ods-button>`,
}) })
export class ButtonWithSpinnerComponent implements OnInit { export class ButtonWithSpinnerComponent implements OnInit {
@Input() text: string = ''; @Input() text: string = '';
...@@ -51,8 +44,6 @@ export class ButtonWithSpinnerComponent implements OnInit { ...@@ -51,8 +44,6 @@ export class ButtonWithSpinnerComponent implements OnInit {
} }
get isError(): boolean { get isError(): boolean {
return ( return isLoaded(this.stateResource) && hasCommandError(<CommandResource>this.stateResource.resource);
isLoaded(this.stateResource) && hasCommandError(<CommandResource>this.stateResource.resource)
);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment