From 45d5c5e2741c7bf2135c09df4096fd6ed075c2a0 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 5 Apr 2021 19:30:15 +0200 Subject: [PATCH] testing input fields. To do: test submit button --- frontend/jest.config.js | 4 +--- frontend/src/views/Pages/Login.spec.js | 27 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/frontend/jest.config.js b/frontend/jest.config.js index 273ecc3c7..9deb88580 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -21,8 +21,6 @@ module.exports = { testMatch: ['**/?(*.)+(spec|test).js?(x)'], // snapshotSerializers: ['jest-serializer-vue'], transformIgnorePatterns: [ - // '/node_modules/', - // '/node_modules/(?!vee-validate/dist/rules)', + '/node_modules/(?!vee-validate/dist/rules)', ], - // preset: '@vue/cli-plugin-unit-jest', } diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js index f4b0ecd1a..14b2e13ff 100644 --- a/frontend/src/views/Pages/Login.spec.js +++ b/frontend/src/views/Pages/Login.spec.js @@ -16,13 +16,12 @@ describe('Login', () => { $t: jest.fn((t) => t), } + let state = { + loginfail: false, + } + let store = new Vuex.Store({ - getters: { - 'auth/isModerator': () => false, - 'auth/user': () => { - return { id: 'some-user' } - }, - }, + state, }) let stubs = { @@ -87,13 +86,21 @@ describe('Login', () => { expect(wrapper.find('button[type="submit"]').exists()).toBeTruthy() }) - it('shows a warining when no valid Email is entered', async () => { + it('shows a warning when no valid Email is entered', async () => { wrapper.find('input[placeholder="Email"]').setValue('no_valid@Email') - //await wrapper.vm.$nextTick() await flushPromises() - //console.log(wrapper.find('fieldset').html()) - await expect(true).toBeTruthy() + await expect(wrapper.find('.invalid-feedback').text()) + .toEqual('The Email field must be a valid email') + }) + + it('shows a warning when password is too short', async () => { + wrapper.find('input[placeholder="form.password"]').setValue('1234') + await flushPromises() + await expect(wrapper.find('.invalid-feedback').text()) + .toEqual('The Password field must be at least 6 characters') }) }) + + // to do: test submit button }) })