ForgotPassword logic change implemented in tests.

This commit is contained in:
elweyn 2021-12-07 10:59:00 +01:00
parent 4b49d85d1a
commit cee7c66a45

View File

@ -8,10 +8,8 @@ const localVue = global.localVue
const mockRouterPush = jest.fn() const mockRouterPush = jest.fn()
describe('ForgotPassword', () => {
let wrapper
const mocks = { const mocks = {
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$router: { $router: {
push: mockRouterPush, push: mockRouterPush,
@ -19,19 +17,43 @@ describe('ForgotPassword', () => {
$apollo: { $apollo: {
query: mockAPIcall, query: mockAPIcall,
}, },
} }
const stubs = { const stubs = {
RouterLink: RouterLinkStub, RouterLink: RouterLinkStub,
} }
const Wrapper = () => { const createMockObject = (comingFrom) => {
return mount(ForgotPassword, { localVue, mocks, stubs }) return {
localVue,
mocks: {
$t: jest.fn((t) => t),
$router: {
push: mockRouterPush,
},
$apollo: {
query: mockAPIcall,
},
$route: {
params: {
comingFrom,
},
},
},
stubs,
}
}
describe('ForgotPassword', () => {
let wrapper
const Wrapper = (functionN) => {
return mount(ForgotPassword, functionN)
} }
describe('mount', () => { describe('mount', () => {
beforeEach(() => { beforeEach(() => {
wrapper = Wrapper() wrapper = Wrapper(createMockObject())
}) })
it('renders the component', () => { it('renders the component', () => {
@ -144,5 +166,15 @@ describe('ForgotPassword', () => {
}) })
}) })
}) })
describe('comingFrom login', () => {
beforeEach(() => {
wrapper = Wrapper(createMockObject('reset'))
})
it('has another subtitle', () => {
expect(wrapper.find('p.text-lead').text()).toEqual('settings.password.resend_subtitle')
})
})
}) })
}) })