summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/code_block_spec.js
blob: 60b0b0b566b90e7ab95b85ac843d8e1a89b48f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { shallowMount } from '@vue/test-utils';
import CodeBlock from '~/vue_shared/components/code_block.vue';

describe('Code Block', () => {
  let wrapper;

  const defaultProps = {
    code: 'test-code',
  };

  const createComponent = (props = {}) => {
    wrapper = shallowMount(CodeBlock, {
      propsData: {
        ...defaultProps,
        ...props,
      },
    });
  };

  afterEach(() => {
    wrapper.destroy();
    wrapper = null;
  });

  describe('with default props', () => {
    beforeEach(() => {
      createComponent();
    });

    it('renders correctly', () => {
      expect(wrapper.element).toMatchSnapshot();
    });
  });

  describe('with maxHeight set to "200px"', () => {
    beforeEach(() => {
      createComponent({ maxHeight: '200px' });
    });

    it('renders correctly', () => {
      expect(wrapper.element).toMatchSnapshot();
    });
  });
});