rename footer to content-footer and simple test App.vue

This commit is contained in:
Moriz Wahl 2021-11-24 09:52:31 +01:00
parent e856c326eb
commit 5c73c9ae69
3 changed files with 13 additions and 50 deletions

View File

@ -1,43 +1,20 @@
import { mount } from '@vue/test-utils'
import { shallowMount } from '@vue/test-utils'
import App from './App'
const localVue = global.localVue
const storeCommitMock = jest.fn()
const mocks = {
$store: {
commit: storeCommitMock,
},
const stubs = {
RouterView: true,
}
const localStorageMock = (() => {
let store = {}
return {
getItem: (key) => {
return store[key] || null
},
setItem: (key, value) => {
store[key] = value.toString()
},
removeItem: (key) => {
delete store[key]
},
clear: () => {
store = {}
},
}
})()
describe('App', () => {
let wrapper
const Wrapper = () => {
return mount(App, { localVue, mocks })
return shallowMount(App, { localVue, stubs })
}
describe('mount', () => {
describe('shallowMount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
@ -46,23 +23,4 @@ describe('App', () => {
expect(wrapper.find('div#app').exists()).toBeTruthy()
})
})
describe('window localStorage is undefined', () => {
it('does not commit a token to the store', () => {
expect(storeCommitMock).not.toBeCalled()
})
})
describe('with token in local storage', () => {
beforeEach(() => {
Object.defineProperty(window, 'localStorage', {
value: localStorageMock,
})
window.localStorage.setItem('vuex', JSON.stringify({ token: 1234 }))
})
it.skip('commits the token to the store', () => {
expect(storeCommitMock).toBeCalledWith('token', 1234)
})
})
})

View File

@ -2,18 +2,18 @@
<div id="app">
<nav-bar class="wrapper-nav" />
<router-view class="wrapper p-3"></router-view>
<foo-ter />
<content-footer />
</div>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import FooTer from '@/components/Footer.vue'
import ContentFooter from '@/components/ContentFooter.vue'
export default {
name: 'App',
components: {
NavBar,
FooTer,
ContentFooter,
},
}
</script>

View File

@ -8,3 +8,8 @@
</div>
</div>
</template>
<script>
export default {
name: 'ContentFooter',
}
</script>