-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bacpop-163-error-handling' of https://github.com/bacpop…
…/beebop into bacpop-115-about-page
- Loading branch information
Showing
12 changed files
with
117 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/client-v2/src/__tests__/composables/useToastService.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useToastService } from "@/composables/useToastService"; | ||
|
||
const mockToastAdd = vitest.fn(); | ||
vitest.mock("primevue/usetoast", () => ({ | ||
useToast: vitest.fn(() => ({ | ||
add: mockToastAdd | ||
})) | ||
})); | ||
describe("useToastService", () => { | ||
it("should call add with correct params when showSuccessToast is called", () => { | ||
const { showSuccessToast } = useToastService(); | ||
|
||
showSuccessToast("Success message"); | ||
|
||
expect(mockToastAdd).toHaveBeenCalledWith({ | ||
severity: "success", | ||
summary: "Success", | ||
detail: "Success message", | ||
life: 5000 | ||
}); | ||
}); | ||
|
||
it("should call add with correct params when showErrorToast is called", () => { | ||
const { showErrorToast } = useToastService(); | ||
|
||
showErrorToast("Error message"); | ||
|
||
expect(mockToastAdd).toHaveBeenCalledWith({ | ||
severity: "error", | ||
summary: "Error", | ||
detail: "Error message", | ||
life: 5000 | ||
}); | ||
}); | ||
|
||
it("should call add with correct params when showInfoToast is called", () => { | ||
const { showInfoToast } = useToastService(); | ||
|
||
showInfoToast("Info message"); | ||
|
||
expect(mockToastAdd).toHaveBeenCalledWith({ | ||
severity: "info", | ||
summary: "Info", | ||
detail: "Info message", | ||
life: 5000 | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useToast } from "primevue/usetoast"; | ||
|
||
export const useToastService = () => { | ||
const toast = useToast(); | ||
|
||
const showSuccessToast = (msg: string) => { | ||
toast.add({ severity: "success", summary: "Success", detail: msg, life: 5000 }); | ||
}; | ||
const showErrorToast = (msg: string) => { | ||
toast.add({ severity: "error", summary: "Error", detail: msg, life: 5000 }); | ||
}; | ||
const showInfoToast = (msg: string) => { | ||
toast.add({ severity: "info", summary: "Info", detail: msg, life: 5000 }); | ||
}; | ||
|
||
return { showSuccessToast, showErrorToast, showInfoToast }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
# TODO: change back to main before merge into main | ||
export API_BRANCH="bacpop-160-network-tab" | ||
export API_BRANCH=main | ||
export DB_LOCATION="./storage/GPS_v6_references" |