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>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/frontend/content_editor/components/wrappers/image_spec.js
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/content_editor/components/wrappers/image_spec.js')
-rw-r--r--spec/frontend/content_editor/components/wrappers/image_spec.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/frontend/content_editor/components/wrappers/image_spec.js b/spec/frontend/content_editor/components/wrappers/image_spec.js
new file mode 100644
index 00000000000..7b057f9cabc
--- /dev/null
+++ b/spec/frontend/content_editor/components/wrappers/image_spec.js
@@ -0,0 +1,66 @@
+import { GlLoadingIcon } from '@gitlab/ui';
+import { NodeViewWrapper } from '@tiptap/vue-2';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
+import ImageWrapper from '~/content_editor/components/wrappers/image.vue';
+
+describe('content/components/wrappers/image', () => {
+ let wrapper;
+
+ const createWrapper = async (nodeAttrs = {}) => {
+ wrapper = shallowMountExtended(ImageWrapper, {
+ propsData: {
+ node: {
+ attrs: nodeAttrs,
+ },
+ },
+ });
+ };
+ const findImage = () => wrapper.findByTestId('image');
+ const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('renders a node-view-wrapper with display-inline-block class', () => {
+ createWrapper();
+
+ expect(wrapper.findComponent(NodeViewWrapper).classes()).toContain('gl-display-inline-block');
+ });
+
+ it('renders an image that displays the node src', () => {
+ const src = 'foobar.png';
+
+ createWrapper({ src });
+
+ expect(findImage().attributes().src).toBe(src);
+ });
+
+ describe('when uploading', () => {
+ beforeEach(() => {
+ createWrapper({ uploading: true });
+ });
+
+ it('renders a gl-loading-icon component', () => {
+ expect(findLoadingIcon().exists()).toBe(true);
+ });
+
+ it('adds gl-opacity-5 class selector to image', () => {
+ expect(findImage().classes()).toContain('gl-opacity-5');
+ });
+ });
+
+ describe('when not uploading', () => {
+ beforeEach(() => {
+ createWrapper({ uploading: false });
+ });
+
+ it('does not render a gl-loading-icon component', () => {
+ expect(findLoadingIcon().exists()).toBe(false);
+ });
+
+ it('does not add gl-opacity-5 class selector to image', () => {
+ expect(findImage().classes()).not.toContain('gl-opacity-5');
+ });
+ });
+});