mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
feat: Raise Test Coverage Frontend
This commit is contained in:
parent
b54558fa68
commit
e8859544f7
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -344,7 +344,7 @@ jobs:
|
|||||||
report_name: Coverage Frontend
|
report_name: Coverage Frontend
|
||||||
type: lcov
|
type: lcov
|
||||||
result_path: ./coverage/lcov.info
|
result_path: ./coverage/lcov.info
|
||||||
min_coverage: 85
|
min_coverage: 86
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
70
frontend/src/views/Pages/SendOverview/GddSend/QrCode.spec.js
Normal file
70
frontend/src/views/Pages/SendOverview/GddSend/QrCode.spec.js
Normal 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()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -44,6 +44,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
scan: false,
|
scan: false,
|
||||||
|
detect: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -55,6 +56,10 @@ export default {
|
|||||||
this.$emit('set-transaction', { email: arr[0].email, amount: arr[0].amount })
|
this.$emit('set-transaction', { email: arr[0].email, amount: arr[0].amount })
|
||||||
this.scan = false
|
this.scan = false
|
||||||
},
|
},
|
||||||
|
async onDetect() {
|
||||||
|
// what is this for? I added the detect data to test that the method is called
|
||||||
|
this.detect = !this.detect
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user