mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
91 lines
2.6 KiB
JavaScript
91 lines
2.6 KiB
JavaScript
import { mount, RouterLinkStub } from '@vue/test-utils'
|
|
import RegisterCommunity from './RegisterCommunity'
|
|
|
|
const localVue = global.localVue
|
|
|
|
const mockStoreCommit = jest.fn()
|
|
|
|
describe('RegisterCommunity', () => {
|
|
let wrapper
|
|
|
|
const mocks = {
|
|
$i18n: {
|
|
locale: 'en',
|
|
},
|
|
$t: jest.fn((t) => t),
|
|
$store: {
|
|
commit: mockStoreCommit,
|
|
state: {
|
|
community: {
|
|
name: '',
|
|
description: '',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
const stubs = {
|
|
RouterLink: RouterLinkStub,
|
|
}
|
|
|
|
const Wrapper = () => {
|
|
return mount(RegisterCommunity, { localVue, mocks, stubs })
|
|
}
|
|
|
|
describe('mount', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('renders the Div Element "#register-community"', () => {
|
|
expect(wrapper.find('div#register-community').exists()).toBeTruthy()
|
|
})
|
|
|
|
describe('Community data already loaded', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks()
|
|
mocks.$store.state.community = {
|
|
name: 'Gradido Entwicklung',
|
|
url: 'http://localhost/',
|
|
registerUrl: 'http://localhost/register',
|
|
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
|
}
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has a Community name', () => {
|
|
expect(wrapper.find('.justify-content-center h1').text()).toBe('Gradido Entwicklung')
|
|
})
|
|
|
|
it('has a Community description', () => {
|
|
expect(wrapper.find('.justify-content-center p').text()).toBe(
|
|
'Die lokale Entwicklungsumgebung von Gradido.',
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('buttons and links', () => {
|
|
it('has a button "Continue to registration?"', () => {
|
|
expect(wrapper.findAll('a').at(0).text()).toEqual('community.continue-to-registration')
|
|
})
|
|
it('button links to /register when clicking "Continue to registration"', () => {
|
|
expect(wrapper.findAll('a').at(0).props().to).toBe('/register')
|
|
})
|
|
|
|
it('has a button "Choose another community?"', () => {
|
|
expect(wrapper.findAll('a').at(1).text()).toEqual('community.choose-another-community')
|
|
})
|
|
it('button links to /select-community when clicking "Choose another community"', () => {
|
|
expect(wrapper.findAll('a').at(1).props().to).toBe('/select-community')
|
|
})
|
|
|
|
it('has a button "Back to Login?"', () => {
|
|
expect(wrapper.findAll('a').at(2).text()).toEqual('back')
|
|
})
|
|
it('button links to /login when clicking "Back to Login"', () => {
|
|
expect(wrapper.findAll('a').at(2).props().to).toBe('/login')
|
|
})
|
|
})
|
|
})
|
|
})
|