@agorize/gommette
Advanced tools
Comparing version 1.15.1 to 1.16.0
@@ -71,3 +71,3 @@ { | ||
}, | ||
"version": "1.15.1", | ||
"version": "1.16.0", | ||
"author": "", | ||
@@ -74,0 +74,0 @@ "keywords": [], |
export default [ | ||
[ | ||
'', | ||
'' | ||
'', | ||
'', | ||
] | ||
] |
@@ -6,2 +6,3 @@ import { shallowMount, createLocalVue } from '@vue/test-utils' | ||
import debounce from 'lodash.debounce' | ||
import renderCases from './GoCookieConsent.render-cases' | ||
@@ -21,2 +22,4 @@ const localVue = createLocalVue() | ||
let checkOffset | ||
let clickOnLink | ||
let onClose | ||
let debounceCheckOffset | ||
@@ -29,2 +32,3 @@ let closeCookieConsent | ||
checkOffset = jest.fn() | ||
clickOnLink = jest.fn() | ||
debounceCheckOffset = jest.fn() | ||
@@ -43,3 +47,4 @@ | ||
checkNewOffset, | ||
checkOffset | ||
checkOffset, | ||
clickOnLink, | ||
} | ||
@@ -62,2 +67,8 @@ }) | ||
it('should add click event listener on document', async () => { | ||
await document.querySelector('body').dispatchEvent(new Event('click')) | ||
expect(clickOnLink).toBeCalled() | ||
}) | ||
it('should set debounceCheckOffset function', () => { | ||
@@ -151,2 +162,49 @@ expect(JSON.stringify(wrapper.vm.debounceCheckOffset)).toEqual(JSON.stringify(debounce(checkNewOffset, 500))) | ||
describe('methods - clickOnLink', () => { | ||
beforeEach(() => { | ||
onClose = jest.fn() | ||
wrapper = shallowMount(GoCookieConsent, { | ||
propsData: { | ||
bodyContent: 'text', | ||
acceptLabel: 'label', | ||
privacyData: { | ||
label: 'privacy data' | ||
} | ||
}, | ||
localVue, | ||
attachToDocument: true, | ||
stubs: ['GoIcon'], | ||
methods: { | ||
checkNewOffset, | ||
checkOffset, | ||
onClose, | ||
} | ||
}) | ||
}) | ||
it('should not called onClose event', async () => { | ||
const clickEvent = new Event('click') | ||
await wrapper.vm.clickOnLink(clickEvent) | ||
expect(onClose).not.toBeCalled() | ||
}) | ||
describe('when target is link element', () => { | ||
it('should called onClose event', async () => { | ||
const link = document.createElement('a') | ||
link.setAttribute('href', 'http://test.com') | ||
let event = { | ||
target: link | ||
} | ||
await wrapper.vm.clickOnLink(event) | ||
expect(onClose).toBeCalled() | ||
}) | ||
}) | ||
}) | ||
describe('methods - onClick', () => { | ||
@@ -153,0 +211,0 @@ beforeEach(() => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12197230
84148