mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Show the comment content if you are a moderator
This commit is contained in:
parent
bb2a6c052e
commit
08d0679a67
@ -15,17 +15,24 @@ describe('Comment.vue', () => {
|
||||
let Wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
let getters
|
||||
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
}
|
||||
getters = {
|
||||
'auth/isModerator': () => false
|
||||
}
|
||||
})
|
||||
|
||||
describe('shallowMount', () => {
|
||||
const Wrapper = () => {
|
||||
return shallowMount(Comment, { propsData, mocks, localVue })
|
||||
const store = new Vuex.Store({
|
||||
getters
|
||||
})
|
||||
return shallowMount(Comment, { store, propsData, mocks, localVue })
|
||||
}
|
||||
|
||||
describe('given a comment', () => {
|
||||
@ -56,6 +63,17 @@ describe('Comment.vue', () => {
|
||||
const expected = [['comment.content.disabled-placeholder']]
|
||||
expect(calls).toEqual(expect.arrayContaining(expected))
|
||||
})
|
||||
|
||||
describe('for a moderator', () => {
|
||||
beforeEach(() => {
|
||||
getters['auth/isModerator'] = () => true
|
||||
})
|
||||
|
||||
it('renders comment data', () => {
|
||||
const wrapper = Wrapper()
|
||||
expect(wrapper.text()).toMatch('comment content')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
comment: {
|
||||
@ -20,8 +22,12 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
isModerator: 'auth/isModerator'
|
||||
}),
|
||||
|
||||
disabled() {
|
||||
return this.comment.disabled
|
||||
return this.comment.disabled && !this.isModerator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user