2020-03-13 15:44:24 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import CodeBlock from '~/vue_shared/components/code_block.vue';
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
describe('Code Block', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
let wrapper;
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const defaultProps = {
|
|
|
|
code: 'test-code',
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper = shallowMount(CodeBlock, {
|
|
|
|
propsData: {
|
2020-05-24 23:13:21 +05:30
|
|
|
...defaultProps,
|
|
|
|
...props,
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
};
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
describe('with default props', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
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-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|