Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 21:08:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 21:08:57 +0300
commitd8121cb00b8bbd281d7362902590b110639bdeba (patch)
tree0a0f71b247b232773a46732d9f74aa3cfed0ef1a /spec/frontend/vue_shared/components
parent536aa3a1f4b96abc4ca34489bf2cbe503afcded7 (diff)
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.js57
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);
+ });
+ });
+ });
+});