Merge branch 'master' into login_call_updateUserInfos

This commit is contained in:
Ulf Gebhardt 2021-11-17 17:02:35 +01:00 committed by GitHub
commit 68fc7bab1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 4 deletions

View File

@ -344,7 +344,7 @@ jobs:
report_name: Coverage Frontend
type: lcov
result_path: ./coverage/lcov.info
min_coverage: 85
min_coverage: 86
token: ${{ github.token }}
##############################################################################

View File

@ -48,7 +48,7 @@ describe('CommunityResolver', () => {
describe('getCommunityInfo', () => {
it('returns the default values', async () => {
expect(query({ query: getCommunityInfoQuery })).resolves.toMatchObject({
await expect(query({ query: getCommunityInfoQuery })).resolves.toMatchObject({
data: {
getCommunityInfo: {
name: 'Gradido Entwicklung',
@ -68,7 +68,7 @@ describe('CommunityResolver', () => {
})
it('returns three communities', async () => {
expect(query({ query: communities })).resolves.toMatchObject({
await expect(query({ query: communities })).resolves.toMatchObject({
data: {
communities: [
{
@ -104,7 +104,7 @@ describe('CommunityResolver', () => {
})
it('returns one community', async () => {
expect(query({ query: communities })).resolves.toMatchObject({
await expect(query({ query: communities })).resolves.toMatchObject({
data: {
communities: [
{

View File

@ -0,0 +1,29 @@
import GlobalComponents from './globalComponents.js'
import Vue from 'vue'
import 'vee-validate'
jest.mock('vue')
jest.mock('vee-validate', () => {
const originalModule = jest.requireActual('vee-validate')
return {
__esModule: true,
...originalModule,
ValidationProvider: 'mocked validation provider',
ValidationObserver: 'mocked validation observer',
}
})
const vueComponentMock = jest.fn()
Vue.component = vueComponentMock
describe('global Components', () => {
GlobalComponents.install(Vue)
it('installs the validation provider', () => {
expect(vueComponentMock).toBeCalledWith('validation-provider', 'mocked validation provider')
})
it('installs the validation observer', () => {
expect(vueComponentMock).toBeCalledWith('validation-observer', 'mocked validation observer')
})
})

View File

@ -0,0 +1,70 @@
import { mount } from '@vue/test-utils'
import QrCode from './QrCode'
const localVue = global.localVue
describe('QrCode', () => {
let wrapper
const mocks = {
$t: jest.fn((t) => t),
}
const stubs = {
QrcodeStream: true,
QrcodeCapture: true,
}
const Wrapper = () => {
return mount(QrCode, { localVue, mocks, stubs })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
it('renders the component', () => {
expect(wrapper.find('div.alert').exists()).toBeTruthy()
})
describe('scanning', () => {
beforeEach(async () => {
wrapper.find('a').trigger('click')
})
it('has a scanning stream', () => {
expect(wrapper.findComponent({ name: 'QrcodeStream' }).exists()).toBeTruthy()
})
describe('decode', () => {
beforeEach(async () => {
await wrapper
.findComponent({ name: 'QrcodeStream' })
.vm.$emit('decode', '[{"email": "user@example.org", "amount": 10.0}]')
})
it('emits set transaction', () => {
expect(wrapper.emitted()['set-transaction']).toEqual([
[
{
email: 'user@example.org',
amount: 10,
},
],
])
})
})
describe('detect', () => {
beforeEach(async () => {
await wrapper.find('div.row > *').vm.$emit('detect')
})
it('calls onDetect', () => {
expect(wrapper.vm.detect).toBeTruthy()
})
})
})
})
})

View File

@ -44,6 +44,7 @@ export default {
data() {
return {
scan: false,
detect: false,
}
},
methods: {
@ -55,6 +56,10 @@ export default {
this.$emit('set-transaction', { email: arr[0].email, amount: arr[0].amount })
this.scan = false
},
async onDetect() {
// TODO: what is this for? I added the detect data to test that the method is called
this.detect = !this.detect
},
},
}
</script>