Show the comment content if you are a moderator

This commit is contained in:
Robert Schäfer 2019-03-14 01:03:34 +01:00
parent bb2a6c052e
commit 08d0679a67
2 changed files with 26 additions and 2 deletions

View File

@ -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')
})
})
})
})
})

View File

@ -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
}
}
}