2020-01-23 13:08:53 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import CodeBlock from '~/vue_shared/components/code_block.vue';
|
2018-07-31 11:50:34 -04:00
|
|
|
|
|
|
|
describe('Code Block', () => {
|
2020-01-23 13:08:53 -05:00
|
|
|
let wrapper;
|
2018-07-31 11:50:34 -04:00
|
|
|
|
2020-05-14 08:08:21 -04:00
|
|
|
const defaultProps = {
|
|
|
|
code: 'test-code',
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
2020-01-23 13:08:53 -05:00
|
|
|
wrapper = shallowMount(CodeBlock, {
|
|
|
|
propsData: {
|
2020-05-14 08:08:21 -04:00
|
|
|
...defaultProps,
|
|
|
|
...props,
|
2020-01-23 13:08:53 -05:00
|
|
|
},
|
2018-07-31 11:50:34 -04:00
|
|
|
});
|
2020-01-23 13:08:53 -05:00
|
|
|
};
|
2018-07-31 11:50:34 -04:00
|
|
|
|
2020-01-23 13:08:53 -05:00
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-07-31 11:50:34 -04:00
|
|
|
});
|
|
|
|
|
2020-05-14 08:08:21 -04:00
|
|
|
describe('with default props', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
2018-07-31 11:50:34 -04:00
|
|
|
|
2020-05-14 08:08:21 -04:00
|
|
|
it('renders correctly', () => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with maxHeight set to "200px"', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ maxHeight: '200px' });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly', () => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
2018-07-31 11:50:34 -04:00
|
|
|
});
|
|
|
|
});
|