-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 709-6-Toggle-In-TopMenu
- Loading branch information
Showing
18 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { vi, describe, it, expect } from 'vitest' | ||
import { toast } from 'vue3-toastify' | ||
|
||
import globalErrorHandler from './globalErrorHandler' | ||
|
||
// vi.mock('vue3-toastify', async (importOriginal) => { | ||
// const mod = await importOriginal<typeof import('vue3-toastify')>() | ||
// return { | ||
// ...mod, | ||
// error: vi.fn(), | ||
// warning: vi.fn(), | ||
// } | ||
// }) | ||
|
||
describe('GlobalErrorHandler', () => { | ||
describe('Error', () => { | ||
const errorSpy = vi.spyOn(toast, 'error') | ||
|
||
it('toasts error message', () => { | ||
globalErrorHandler.error('someError') | ||
|
||
expect(errorSpy).toBeCalledWith('someError') | ||
}) | ||
}) | ||
|
||
describe('Warning', () => { | ||
const warningSpy = vi.spyOn(toast, 'warning') | ||
|
||
it('toasts warning message', () => { | ||
globalErrorHandler.warning('someWarning') | ||
|
||
expect(warningSpy).toBeCalledWith('someWarning') | ||
}) | ||
}) | ||
}) |
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,20 @@ | ||
import { App } from 'vue' | ||
import { toast } from 'vue3-toastify' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const handleError = (message: string, data?: unknown) => { | ||
toast.error(message) | ||
} | ||
const handleWarning = (message: string) => { | ||
toast.warning(message) | ||
} | ||
|
||
export default { | ||
install: (app: App) => { | ||
app.config.errorHandler = (error, vm, info) => { | ||
handleError(`Unhandled error occurred: ${info}`, error) | ||
} | ||
}, | ||
error: handleError, | ||
warning: handleWarning, | ||
} |
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,9 @@ | ||
import { config } from '@vue/test-utils' | ||
import { vi } from 'vitest' | ||
|
||
import globalErrorHandler from '#plugins/globalErrorHandler' | ||
|
||
export const errorHandlerSpy = vi.spyOn(globalErrorHandler, 'error') | ||
export const warningHandlerSpy = vi.spyOn(globalErrorHandler, 'warning') | ||
|
||
config.global.plugins.push(globalErrorHandler) |
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
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
Oops, something went wrong.