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,30 +8,52 @@ const localVue = global.localVue
const mockRouterPush = jest.fn() const mockRouterPush = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
$router: {
push: mockRouterPush,
},
$apollo: {
query: mockAPIcall,
},
}
const stubs = {
RouterLink: RouterLinkStub,
}
const createMockObject = (comingFrom) => {
return {
localVue,
mocks: {
$t: jest.fn((t) => t),
$router: {
push: mockRouterPush,
},
$apollo: {
query: mockAPIcall,
},
$route: {
params: {
comingFrom,
},
},
},
stubs,
}
}
describe('ForgotPassword', () => { describe('ForgotPassword', () => {
let wrapper let wrapper
const mocks = { const Wrapper = (functionN) => {
$t: jest.fn((t) => t), return mount(ForgotPassword, functionN)
$router: {
push: mockRouterPush,
},
$apollo: {
query: mockAPIcall,
},
}
const stubs = {
RouterLink: RouterLinkStub,
}
const Wrapper = () => {
return mount(ForgotPassword, { localVue, mocks, stubs })
} }
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')
})
})
}) })
}) })