Skip to content

Commit

Permalink
Fixed toastId returning undefined when using Toastr.error (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmathew900 authored May 7, 2024
1 parent 227b2cd commit 6799863
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Toastr/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const withParsedErrorMsg =
const { buttonLabel, onClick, customConfig } =
parseToastrConfig(toastrConfig);

toastrFunc(errorMessage, {
return toastrFunc(errorMessage, {
buttonLabel,
onClick,
role: "alert",
Expand Down
9 changes: 5 additions & 4 deletions tests/Toastr.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@ describe("Toastr", () => {
testToastrErrorMessages(errorResponse, expectedMessage);
});

it("should return toastId when toastr is called", () => {
const successMessage = "This is a success toastr.";
const toastId = Toastr.success(successMessage);
expect(toastId).toBeDefined();
["Success", "Info", "Warning", "Error"].forEach(type => {
it(`should return toastId when ${type} Toastr is called`, () => {
const toastId = Toastr[type.toLowerCase()](`This is a ${type} toastr.`);
expect(toastId).toBeDefined();
});
});
});
2 changes: 1 addition & 1 deletion types/Toastr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type ToastrFunction = (
message: React.ReactNode,
buttonLabel?: React.ReactNode,
onClick?: () => void
) => void;
) => string | null;

const Toastr: {
show: ToastrFunction;
Expand Down

0 comments on commit 6799863

Please sign in to comment.