mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
more tests
This commit is contained in:
parent
5fefac0fd7
commit
52fba0e0bc
@ -0,0 +1,54 @@
|
|||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import ContributionMessagesList from './ContributionMessagesList.vue'
|
||||||
|
|
||||||
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
describe('ContributionMessagesList', () => {
|
||||||
|
let wrapper
|
||||||
|
|
||||||
|
const mocks = {
|
||||||
|
$t: jest.fn((t) => t),
|
||||||
|
$store: {
|
||||||
|
state: {
|
||||||
|
firstName: 'Peter',
|
||||||
|
lastName: 'Lustig',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const propsData = {
|
||||||
|
contributionId: 42,
|
||||||
|
state: 'PENDING0',
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
id: 111,
|
||||||
|
message: 'asd asda sda sda',
|
||||||
|
createdAt: '2022-08-29T12:23:27.000Z',
|
||||||
|
updatedAt: null,
|
||||||
|
type: 'DIALOG',
|
||||||
|
userFirstName: 'Peter',
|
||||||
|
userLastName: 'Lustig',
|
||||||
|
userId: 107,
|
||||||
|
__typename: 'ContributionMessage',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(ContributionMessagesList, {
|
||||||
|
localVue,
|
||||||
|
mocks,
|
||||||
|
propsData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a DIV .contribution-messages-list-item', () => {
|
||||||
|
expect(wrapper.find('div.contribution-messages-list-item').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="contribution-messages-list-item">
|
||||||
<is-not-moderator v-if="isNotModerator" :message="message"></is-not-moderator>
|
<is-not-moderator v-if="isNotModerator" :message="message"></is-not-moderator>
|
||||||
<is-moderator v-else :message="message"></is-moderator>
|
<is-moderator v-else :message="message"></is-moderator>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import IsModerator from './IsModerator.vue'
|
||||||
|
|
||||||
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
describe('IsModerator', () => {
|
||||||
|
let wrapper
|
||||||
|
|
||||||
|
const mocks = {
|
||||||
|
$t: jest.fn((t) => t),
|
||||||
|
}
|
||||||
|
|
||||||
|
const propsData = {
|
||||||
|
message: {
|
||||||
|
id: 111,
|
||||||
|
message: 'asd asda sda sda',
|
||||||
|
createdAt: '2022-08-29T12:23:27.000Z',
|
||||||
|
updatedAt: null,
|
||||||
|
type: 'DIALOG',
|
||||||
|
userFirstName: 'Peter',
|
||||||
|
userLastName: 'Lustig',
|
||||||
|
userId: 107,
|
||||||
|
__typename: 'ContributionMessage',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(IsModerator, {
|
||||||
|
localVue,
|
||||||
|
mocks,
|
||||||
|
propsData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a DIV .slot-is-moderator', () => {
|
||||||
|
expect(wrapper.find('div.slot-is-moderator').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('props.message.default', () => {
|
||||||
|
expect(wrapper.vm.$options.props.message.default.call()).toEqual({})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -1,10 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="slot-is-moderator">
|
<div class="slot-is-moderator">
|
||||||
<b-avatar
|
<b-avatar square :text="moderatorName" variant="warning"></b-avatar>
|
||||||
square
|
|
||||||
:text="`${message.userFirstName[0]} ${message.userLastName[0]}`"
|
|
||||||
variant="warning"
|
|
||||||
></b-avatar>
|
|
||||||
<span class="ml-2 mr-2">
|
<span class="ml-2 mr-2">
|
||||||
{{ message.userFirstName }} {{ message.userLastName }}
|
{{ message.userFirstName }} {{ message.userLastName }}
|
||||||
<small class="ml-4 text-success">{{ $t('community.moderator') }}</small>
|
<small class="ml-4 text-success">{{ $t('community.moderator') }}</small>
|
||||||
@ -22,6 +18,11 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
moderatorName() {
|
||||||
|
return `${this.message.userFirstName[0]} ${this.message.userLastName[0]}`
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import IsNotModerator from './IsNotModerator.vue'
|
||||||
|
|
||||||
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
describe('IsNotModerator', () => {
|
||||||
|
let wrapper
|
||||||
|
|
||||||
|
const mocks = {
|
||||||
|
$t: jest.fn((t) => t),
|
||||||
|
}
|
||||||
|
|
||||||
|
const propsData = {
|
||||||
|
message: {
|
||||||
|
id: 113,
|
||||||
|
message: 'asda sdad ad asdasd ',
|
||||||
|
createdAt: '2022-08-29T12:25:34.000Z',
|
||||||
|
updatedAt: null,
|
||||||
|
type: 'DIALOG',
|
||||||
|
userFirstName: 'Bibi',
|
||||||
|
userLastName: 'Bloxberg',
|
||||||
|
userId: 108,
|
||||||
|
__typename: 'ContributionMessage',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const Wrapper = () => {
|
||||||
|
return mount(IsNotModerator, {
|
||||||
|
localVue,
|
||||||
|
mocks,
|
||||||
|
propsData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has a DIV .slot-is-not-moderator', () => {
|
||||||
|
expect(wrapper.find('div.slot-is-not-moderator').exists()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('props.message.default', () => {
|
||||||
|
expect(wrapper.vm.$options.props.message.default.call()).toEqual({})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -1,10 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="slot-is-not-moderator">
|
<div class="slot-is-not-moderator">
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<b-avatar
|
<b-avatar :text="userName" variant="info"></b-avatar>
|
||||||
:text="`${message.userFirstName[0]} ${message.userLastName[0]}`"
|
|
||||||
variant="info"
|
|
||||||
></b-avatar>
|
|
||||||
<span class="ml-2 mr-2 text-bold">
|
<span class="ml-2 mr-2 text-bold">
|
||||||
{{ message.userFirstName }} {{ message.userLastName }}
|
{{ message.userFirstName }} {{ message.userLastName }}
|
||||||
</span>
|
</span>
|
||||||
@ -22,6 +19,11 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
userName() {
|
||||||
|
return `${this.message.userFirstName[0]} ${this.message.userLastName[0]}`
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user