mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Start to implement wrapper modal
This commit is contained in:
parent
f247e8657e
commit
03422920a2
64
components/Modal.spec.js
Normal file
64
components/Modal.spec.js
Normal file
@ -0,0 +1,64 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import Modal from './Modal.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import { getters, mutations } from '../store/modal'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('Modal.vue', () => {
|
||||
let Wrapper
|
||||
let store
|
||||
let state
|
||||
let mocks
|
||||
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
$t: () => {}
|
||||
}
|
||||
state = {
|
||||
open: null,
|
||||
data: {}
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
let wrapper
|
||||
const Wrapper = () => {
|
||||
store = new Vuex.Store({
|
||||
state,
|
||||
getters: {
|
||||
'modal/open': getters.open,
|
||||
'modal/data': getters.data
|
||||
},
|
||||
mutations: {
|
||||
'modal/SET_OPEN': mutations.SET_OPEN
|
||||
}
|
||||
})
|
||||
return mount(Modal, { store, mocks, localVue })
|
||||
}
|
||||
|
||||
it('renders nothing', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.isEmpty()).toBe(true)
|
||||
})
|
||||
|
||||
describe('store opens a report', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
open: 'report',
|
||||
data: {}
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('renders report modal', () => {
|
||||
expect(wrapper.contains('#modal-report')).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
24
components/Modal.vue
Normal file
24
components/Modal.vue
Normal file
@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<report-modal v-if="showReportModal" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ReportModal from '~/components/ReportModal'
|
||||
|
||||
export default {
|
||||
name: 'Modal',
|
||||
components: {
|
||||
ReportModal
|
||||
},
|
||||
computed: {
|
||||
showReportModal() {
|
||||
return this.$store.getters['modal/open'] === 'report'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.$store.commit('modal/SET_OPEN', {})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user