Unit tests for FigureQrCode

This commit is contained in:
elweyn 2023-03-31 16:02:05 +02:00
parent bd29624c79
commit 06523f38fa

View File

@ -22,12 +22,62 @@ describe('FigureQrCode', () => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
it('renders the Div Element ".figure-qr-code"', () => { afterEach(() => {
expect(wrapper.find('div.figure-qr-code').exists()).toBeTruthy() jest.clearAllMocks()
}) })
it('renders the Div Element "q-r-canvas"', () => { it('has options filled', () => {
expect(wrapper.find('q-r-canvas')) expect(wrapper.vm.options).toEqual({
cellSize: 8,
correctLevel: 'H',
data: '',
})
})
it('renders the Div Element ".figure-qr-code"', () => {
expect(wrapper.find('div.figure-qr-code').exists()).toBe(true)
})
it('renders the Div Element "qrbox"', () => {
expect(wrapper.find('div.qrbox').exists()).toBe(true)
})
it('renders the Canvas Element "#qrcanvas"', () => {
const canvas = wrapper.find('#qrcanvas')
// console.log(canvas.html())
expect(canvas.exists()).toBe(true)
// Hier können Sie weitere Tests für das Canvas-Element durchführen
// z.B. überprüfen Sie die Breite und Höhe des Canvas-Elements oder den Canvas-Kontext
const canvasEl = canvas.element
const canvasWidth = canvasEl.width
const canvasHeight = canvasEl.height
expect(canvasWidth).toBeGreaterThan(0)
expect(canvasHeight).toBeGreaterThan(0)
const canvasContext = canvasEl.getContext('2d')
expect(canvasContext).not.toBeNull()
})
it('renders the A Element "#download"', () => {
const downloadLink = wrapper.find('#download')
expect(downloadLink.exists()).toBe(true)
})
describe('Download QR-Code link', () => {
beforeEach(() => {
const downloadLink = wrapper.find('#download')
downloadLink.trigger('click')
// await wrapper.vm.$nextTick()
})
it('click the A Element "#download" set an href', () => {
// expect(toDataURLStub).toHaveBeenCalledWith('image/png')
expect(wrapper.find('#download').attributes('href')).toEqual('')
})
}) })
}) })
}) })