Commit f8c27542 authored by Tom Quirk's avatar Tom Quirk

Test createDesignDetailFlash util fn

Added unit and "integration" tests for
createDesignDetailFlash util function
parent da36d6e8
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management design index page flash container is in correct position in DOM 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
>
<div
class="d-flex overflow-hidden flex-lg-grow-1 flex-column"
>
<designdestroyer-stub
filenames="test.jpg"
iid="1"
projectpath=""
/>
<div
class="d-flex flex-column h-100 mh-100 position-relative"
>
<div
class="p-3"
>
<div
class="flash-container"
/>
</div>
<designimage-stub
image="test.jpg"
name="test.jpg"
/>
<designoverlay-stub
notes=""
position="[object Object]"
/>
</div>
</div>
<div
class="image-notes"
>
<h2
class="new-discussion-disclaimer m-0"
>
Click the image where you'd like to start a new discussion
</h2>
</div>
</div>
`;
exports[`Design management design index page renders design index 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
......
......@@ -4,6 +4,7 @@ import DesignIndex from 'ee/design_management/pages/design/index.vue';
import DesignDiscussion from 'ee/design_management/components/design_notes/design_discussion.vue';
import DesignReplyForm from 'ee/design_management/components/design_notes/design_reply_form.vue';
import createImageDiffNoteMutation from 'ee/design_management/graphql/mutations/createImageDiffNote.mutation.graphql';
import * as utils from 'ee/design_management/utils/design_management_utils';
import design from '../../mock_data/design';
jest.mock('mousetrap', () => ({
......@@ -175,4 +176,37 @@ describe('Design management design index page', () => {
expect(findDiscussionForm().exists()).toBe(false);
});
});
describe('flash', () => {
beforeEach(() => {
setDesign();
wrapper.setData({
design: {
...design,
discussions: {
edges: [],
},
},
});
});
it('container is in correct position in DOM', () => {
wrapper.vm.$nextTick(() => {
// tests that `design-detail` class exists on Component container,
// and that the '.flash-container' element exists and is placed correctly
expect(wrapper.element).toMatchSnapshot();
});
});
it('creates flash on mutation error', () => {
const createDesignDetailFlash = jest.fn();
// eslint-disable-next-line import/no-named-as-default-member
utils.createDesignDetailFlash = createDesignDetailFlash;
try {
wrapper.vm.onMutationError('test error');
} catch (e) {
expect(createDesignDetailFlash).toHaveBeenCalled();
}
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment