0
0
Fork 0
mirror of https://github.com/alerta/alerta-webui.git synced 2025-03-17 05:52:37 +00:00
alerta_alerta-webui/tests/unit/components/ApiKeyList.spec.ts
2019-01-21 01:13:47 +01:00

54 lines
1.3 KiB
TypeScript

import { shallowMount } from '@vue/test-utils'
import ApiKeyList from '@/components/ApiKeyList.vue'
import Vue from 'vue'
import Vuex, { Store } from 'vuex'
import Vuetify from 'vuetify'
Vue.config.silent = true
Vue.use(Vuetify)
Vue.use(Vuex)
describe('ApiKeyList', () => {
let store: Store<any>
beforeEach(() => {
store = new Vuex.Store({
state: {
keys: [
{
count: 0,
customer: 'Google',
expireTime: '2020-01-11T17:37:48.569Z',
href:
'http://api.local.alerta.io:8080/key/vj50CYx04fpviPlyhQiz-l_XVOPZsWzSR9PIzRHH',
id: '4429e9bf-f7b7-4a9d-b1bd-7252ee84635d',
key: 'vj50CYx04fpviPlyhQiz-l_XVOPZsWzSR9PIzRHH',
lastUsedTime: null,
scopes: ['write', 'read'],
text: '',
type: 'read-write',
user: 'nfsatterly@gmail.com'
}
],
perms: {
permissions: [],
scopes: []
}
},
getters: {
['auth/scopes']() {
return ['read', 'write'] // default user scopes
}
}
})
})
it('renders props.msg when passed', () => {
const msg = 'Sorry, nothing to display here :('
const wrapper = shallowMount(ApiKeyList, {
propsData: { msg },
store
})
expect(wrapper.text()).toMatch(msg)
})
})