diff --git a/jest.config.js b/jest.config.js index 6b689d0c9..6d4c31db9 100755 --- a/jest.config.js +++ b/jest.config.js @@ -41,8 +41,8 @@ module.exports = { testMatch: [ // Matches tests in any subfolder of 'src' or into 'test/jest/__tests__' // Matches all files with extension 'js', 'jsx', 'ts' and 'tsx' - '/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)', - //'/src/**/*.jest.(spec|test).+(ts|js)?(x)', + // '/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)', + '/src/**/__tests__/*.(spec|test).+(ts|js)?(x)', ], // Extension-less imports of components are resolved to .ts files by TS, // grating correct type-checking in test files. diff --git a/src/components/__tests__/UserPanel.spec.js b/src/components/__tests__/UserPanel.spec.js new file mode 100644 index 000000000..a81584081 --- /dev/null +++ b/src/components/__tests__/UserPanel.spec.js @@ -0,0 +1,28 @@ +import { describe, expect, it } from '@jest/globals'; +import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-jest'; +import { mount } from '@vue/test-utils'; +import { i18n } from 'src/boot/i18n'; +import UserPanel from '../UserPanel.vue'; + +// Specify here Quasar config you'll need to test your component +installQuasarPlugin(); +const routerPushMock = jest.fn(); + +jest.mock('vue-router', () => ({ + useRouter: () => ({ + push: routerPushMock, + }), +})); + +describe('UserPanel', () => { + it('should have the function logout defined', () => { + const wrapper = mount(UserPanel, { + global: { + plugins: [i18n] + } + }); + const { vm } = wrapper; + + expect(vm.logout).toBeDefined(); + }); +}); diff --git a/src/pages/Login/Login.vue b/src/pages/Login/Login.vue index ff3a923e2..ac76163fa 100644 --- a/src/pages/Login/Login.vue +++ b/src/pages/Login/Login.vue @@ -11,14 +11,25 @@ true-value="en" v-model="locale" /> - +