diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 18:08:57 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 18:08:57 +0000 |
commit | d8121cb00b8bbd281d7362902590b110639bdeba (patch) | |
tree | 0a0f71b247b232773a46732d9f74aa3cfed0ef1a /spec/frontend/vue_shared/components | |
parent | 536aa3a1f4b96abc4ca34489bf2cbe503afcded7 (diff) | |
download | gitlab-ce-d8121cb00b8bbd281d7362902590b110639bdeba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components')
-rw-r--r-- | spec/frontend/vue_shared/components/dismissible_alert_spec.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/dismissible_alert_spec.js b/spec/frontend/vue_shared/components/dismissible_alert_spec.js new file mode 100644 index 00000000000..17905254292 --- /dev/null +++ b/spec/frontend/vue_shared/components/dismissible_alert_spec.js @@ -0,0 +1,57 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlAlert } from '@gitlab/ui'; +import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue'; + +const TEST_HTML = 'Hello World! <strong>Foo</strong>'; + +describe('vue_shared/components/dismissible_alert', () => { + const testAlertProps = { + primaryButtonText: 'Lorem ipsum', + primaryButtonLink: '/lorem/ipsum', + }; + + let wrapper; + + const createComponent = (props = {}) => { + wrapper = shallowMount(DismissibleAlert, { + propsData: { + html: TEST_HTML, + ...testAlertProps, + ...props, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + const findAlert = () => wrapper.find(GlAlert); + + describe('with default', () => { + beforeEach(() => { + createComponent(); + }); + + it('shows alert', () => { + const alert = findAlert(); + + expect(alert.exists()).toBe(true); + expect(alert.props()).toEqual(expect.objectContaining(testAlertProps)); + }); + + it('shows given HTML', () => { + expect(findAlert().html()).toContain(TEST_HTML); + }); + + describe('when dismissed', () => { + beforeEach(() => { + findAlert().vm.$emit('dismiss'); + }); + + it('hides the alert', () => { + expect(findAlert().exists()).toBe(false); + }); + }); + }); +}); |