Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): add cookie consent (#179)
closes #178
- Loading branch information
1 parent
0e2c021
commit a30fad4
Showing
15 changed files
with
336 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/app/shared/animations/FadeAnimation/FadeAnimation.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils'; | ||
import FadeAnimation from './FadeAnimation.vue'; | ||
|
||
const localVue = createLocalVue(); | ||
|
||
describe('FadeAnimation.vue', () => { | ||
|
||
test('renders component', () => { | ||
const wrapper = mount(FadeAnimation, | ||
{ | ||
localVue, | ||
slots: { | ||
default: '<div>foo</div>', | ||
}, | ||
}, | ||
); | ||
|
||
expect(wrapper.text()).toBe('foo'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<template> | ||
<transition | ||
:enter-class="$style.enter" | ||
:enter-active-class="$style.enterActive" | ||
:enter-to-class="$style.enterTo" | ||
:leave-class="$style.leave" | ||
:leave-active-class="$style.leaveActive" | ||
:leave-to-class="$style.leaveTo"> | ||
<slot /> | ||
</transition> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: 'FadeAnimation', | ||
}; | ||
</script> | ||
|
||
<style lang="scss" module> | ||
@import "../../styles"; | ||
.enterActive, .leaveActive { | ||
transition: $fade-animation-transition; | ||
} | ||
.enterTo, .leave { | ||
opacity: 1; | ||
} | ||
.enter, .leaveTo { | ||
opacity: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/app/shared/components/VueCookieConsent/VueCookieConsent.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils'; | ||
import VueCookieConsent from './VueCookieConsent.vue'; | ||
|
||
const localVue = createLocalVue(); | ||
|
||
describe('VueCookieConsent.vue', () => { | ||
|
||
test('renders visible component and simulates consent click', () => { | ||
const setCookieConsentVersion: any = jest.fn(); | ||
|
||
const wrapper = mount(VueCookieConsent, | ||
{ | ||
localVue, | ||
slots: { | ||
default: 'foo', | ||
}, | ||
propsData: { | ||
currentVersion: '1.1.0', | ||
cookieConsentVersion: '1.0.0', | ||
setCookieConsentVersion, | ||
}, | ||
}, | ||
) as any; | ||
|
||
expect(wrapper.text()).toBe('foo'); | ||
expect(wrapper.findAll('.button')).toHaveLength(1); | ||
expect(wrapper.vm.show).toBeTruthy(); | ||
|
||
wrapper.find('.button').trigger('click'); | ||
|
||
expect(setCookieConsentVersion).toHaveBeenCalledWith('1.1.0'); | ||
}); | ||
|
||
test('renders hidden component', () => { | ||
const wrapper = mount(VueCookieConsent, | ||
{ | ||
localVue, | ||
slots: { | ||
default: 'foo', | ||
}, | ||
propsData: { | ||
currentVersion: '1.0.0', | ||
cookieConsentVersion: '1.0.0', | ||
setCookieConsentVersion: jest.fn(), | ||
}, | ||
}, | ||
) as any; | ||
|
||
expect(wrapper.text()).toBe(''); | ||
expect(wrapper.findAll('.button')).toHaveLength(0); | ||
expect(wrapper.vm.show).toBeFalsy(); | ||
}); | ||
|
||
test('test watchers', () => { | ||
const wrapper = mount(VueCookieConsent, | ||
{ | ||
localVue, | ||
slots: { | ||
default: 'foo', | ||
}, | ||
propsData: { | ||
currentVersion: '1.1.0', | ||
cookieConsentVersion: '1.0.0', | ||
setCookieConsentVersion: jest.fn(), | ||
}, | ||
}, | ||
) as any; | ||
|
||
expect(wrapper.text()).toBe('foo'); | ||
expect(wrapper.findAll('.button')).toHaveLength(1); | ||
expect(wrapper.vm.show).toBeTruthy(); | ||
|
||
wrapper.setProps({ cookieConsentVersion: '1.1.0' }); | ||
expect(wrapper.vm.show).toBeFalsy(); | ||
|
||
wrapper.setProps({ cookieConsentVersion: '1.0.0' }); | ||
expect(wrapper.vm.show).toBeTruthy(); | ||
}); | ||
|
||
}); |
18 changes: 18 additions & 0 deletions
18
src/app/shared/components/VueCookieConsent/VueCookieConsent.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { storiesOf } from '@storybook/vue'; | ||
import { action } from '@storybook/addon-actions'; | ||
import VueInfoAddon from 'storybook-addon-vue-info'; | ||
import VueCookieConsent from './VueCookieConsent.vue'; | ||
|
||
const story = (storiesOf('VueCookieConsent', module) as any); | ||
|
||
story.addDecorator(VueInfoAddon); | ||
|
||
story.add('Default', () => ({ | ||
components: { VueCookieConsent }, | ||
template: `<vue-cookie-consent current-version="1.0.0" cookie-consent-version="" :set-cookie-consent-version="action"> | ||
VueCookieConsent | ||
</vue-cookie-consent>`, | ||
methods: { | ||
action: action('@onClick'), | ||
}, | ||
})); |
Oops, something went wrong.