fix test for router and navbar

This commit is contained in:
ogerly 2022-08-17 11:05:40 +02:00
parent 0be22fcc27
commit ead9f5be7d
2 changed files with 83 additions and 86 deletions

View File

@ -49,7 +49,7 @@ describe('Navbar', () => {
}) })
it('has twelve b-nav-item in the navbar', () => { it('has twelve b-nav-item in the navbar', () => {
expect(wrapper.findAll('.nav-item')).toHaveLength(12) expect(wrapper.findAll('.nav-item')).toHaveLength(13)
}) })
it('has first nav-item "amount GDD" in navbar', () => { it('has first nav-item "amount GDD" in navbar', () => {
@ -81,24 +81,24 @@ describe('Navbar', () => {
}) })
it('has first nav-item "navigation.info" in navbar', () => { it('has first nav-item "navigation.info" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.info') expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.info')
}) })
}) })
describe('navigation Navbar (user has an elopage account)', () => { describe('navigation Navbar (user has an elopage account)', () => {
it('has a link to the members area', () => { it('has a link to the members area', () => {
expect(wrapper.findAll('.nav-item').at(9).text()).toContain('navigation.members_area') expect(wrapper.findAll('.nav-item').at(10).text()).toContain('navigation.members_area')
expect(wrapper.findAll('.nav-item').at(9).find('a').attributes('href')).toBe( expect(wrapper.findAll('.nav-item').at(10).find('a').attributes('href')).toBe(
'https://elopage.com', 'https://elopage.com',
) )
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(11).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(11).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(12).text()).toEqual('navigation.logout')
}) })
}) })
@ -109,11 +109,11 @@ describe('Navbar', () => {
}) })
it('has first nav-item "navigation.admin_area" in navbar', () => { it('has first nav-item "navigation.admin_area" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.admin_area') expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.admin_area')
}) })
it('has first nav-item "navigation.logout" in navbar', () => { it('has first nav-item "navigation.logout" in navbar', () => {
expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.logout') expect(wrapper.findAll('.nav-item').at(11).text()).toEqual('navigation.logout')
}) })
}) })
}) })

View File

@ -50,7 +50,7 @@ describe('router', () => {
}) })
it('has sixteen routes defined', () => { it('has sixteen routes defined', () => {
expect(routes).toHaveLength(18) expect(routes).toHaveLength(19)
}) })
describe('overview', () => { describe('overview', () => {
@ -127,94 +127,91 @@ describe('router', () => {
it('loads the "InfoStatistic" page', async () => { it('loads the "InfoStatistic" page', async () => {
const component = await routes.find((r) => r.path === '/info').component() const component = await routes.find((r) => r.path === '/info').component()
expect(component.default.name).toBe('InfoStatistic') expect(component.default.name).toBe('InfoStatistic')
})
})
describe('gdt', () => {
it('requires authorization', () => {
expect(routes.find((r) => r.path === '/gdt').meta.requiresAuth).toBeTruthy()
})
describe('gdt', () => { it('loads the "GDT" page', async () => {
it('requires authorization', () => { const component = await routes.find((r) => r.path === '/gdt').component()
expect(routes.find((r) => r.path === '/gdt').meta.requiresAuth).toBeTruthy() expect(component.default.name).toBe('Transactions')
}) })
})
it('loads the "GDT" page', async () => { describe('login', () => {
const component = await routes.find((r) => r.path === '/gdt').component() it('loads the "Login" page', async () => {
expect(component.default.name).toBe('Transactions') const component = await routes.find((r) => r.path === '/login/:code?').component()
}) expect(component.default.name).toBe('Login')
}) })
})
describe('login', () => { describe('register', () => {
it('loads the "Login" page', async () => { it('loads the "register" page', async () => {
const component = await routes.find((r) => r.path === '/login/:code?').component() const component = await routes.find((r) => r.path === '/register/:code?').component()
expect(component.default.name).toBe('Login') expect(component.default.name).toBe('Register')
}) })
}) })
describe('register', () => { describe('forgot password', () => {
it('loads the "register" page', async () => { it('loads the "ForgotPassword" page', async () => {
const component = await routes.find((r) => r.path === '/register/:code?').component() const component = await routes.find((r) => r.path === '/forgot-password').component()
expect(component.default.name).toBe('Register') expect(component.default.name).toBe('ForgotPassword')
}) })
}) })
describe('forgot password', () => { describe('password with param comingFrom', () => {
it('loads the "ForgotPassword" page', async () => { it('loads the "ForgotPassword" page', async () => {
const component = await routes.find((r) => r.path === '/forgot-password').component() const component = await routes
expect(component.default.name).toBe('ForgotPassword') .find((r) => r.path === '/forgot-password/:comingFrom')
}) .component()
}) expect(component.default.name).toBe('ForgotPassword')
})
})
describe('password with param comingFrom', () => { describe('register-community', () => {
it('loads the "ForgotPassword" page', async () => { it('loads the "registerCommunity" page', async () => {
const component = await routes const component = await routes.find((r) => r.path === '/register-community').component()
.find((r) => r.path === '/forgot-password/:comingFrom') expect(component.default.name).toBe('RegisterCommunity')
.component() })
expect(component.default.name).toBe('ForgotPassword') })
})
})
describe('register-community', () => { describe('select-community', () => {
it('loads the "registerCommunity" page', async () => { it('loads the "SelectCommunity" page', async () => {
const component = await routes const component = await routes.find((r) => r.path === '/select-community').component()
.find((r) => r.path === '/register-community') expect(component.default.name).toBe('SelectCommunity')
.component() })
expect(component.default.name).toBe('RegisterCommunity') })
})
})
describe('select-community', () => { describe('reset password', () => {
it('loads the "SelectCommunity" page', async () => { it('loads the "ResetPassword" page', async () => {
const component = await routes.find((r) => r.path === '/select-community').component() const component = await routes
expect(component.default.name).toBe('SelectCommunity') .find((r) => r.path === '/reset-password/:optin')
}) .component()
}) expect(component.default.name).toBe('ResetPassword')
})
})
describe('reset password', () => { describe('checkEmail', () => {
it('loads the "ResetPassword" page', async () => { it('loads the "CheckEmail" page', async () => {
const component = await routes const component = await routes
.find((r) => r.path === '/reset-password/:optin') .find((r) => r.path === '/checkEmail/:optin/:code?')
.component() .component()
expect(component.default.name).toBe('ResetPassword') expect(component.default.name).toBe('ResetPassword')
}) })
}) })
describe('checkEmail', () => { describe('redeem', () => {
it('loads the "CheckEmail" page', async () => { it('loads the "TransactionLink" page', async () => {
const component = await routes const component = await routes.find((r) => r.path === '/redeem/:code').component()
.find((r) => r.path === '/checkEmail/:optin/:code?') expect(component.default.name).toBe('TransactionLink')
.component() })
expect(component.default.name).toBe('ResetPassword') })
})
})
describe('redeem', () => { describe('not found page', () => {
it('loads the "TransactionLink" page', async () => { it('renders the "NotFound" page', async () => {
const component = await routes.find((r) => r.path === '/redeem/:code').component() expect(routes.find((r) => r.path === '*').component).toEqual(NotFound)
expect(component.default.name).toBe('TransactionLink')
})
})
describe('not found page', () => {
it('renders the "NotFound" page', async () => {
expect(routes.find((r) => r.path === '*').component).toEqual(NotFound)
})
})
}) })
}) })
}) })