debian-mirror-gitlab/spec/frontend/vue_shared/components/identicon_spec.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils';
import IdenticonComponent from '~/vue_shared/components/identicon.vue';
describe('Identicon', () => {
let wrapper;
2020-05-24 23:13:21 +05:30
const defaultProps = {
entityId: 1,
entityName: 'entity-name',
sizeClass: 's40',
};
const createComponent = (props = {}) => {
2020-03-13 15:44:24 +05:30
wrapper = shallowMount(IdenticonComponent, {
propsData: {
2020-05-24 23:13:21 +05:30
...defaultProps,
...props,
2020-03-13 15:44:24 +05:30
},
2017-09-10 17:25:29 +05:30
});
2020-03-13 15:44:24 +05:30
};
2017-09-10 17:25:29 +05:30
2020-03-13 15:44:24 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
2017-09-10 17:25:29 +05:30
});
2020-05-24 23:13:21 +05:30
describe('entity id is a number', () => {
2020-10-24 23:57:45 +05:30
beforeEach(() => createComponent());
2020-05-24 23:13:21 +05:30
it('matches snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
2018-03-17 18:26:18 +05:30
2020-05-24 23:13:21 +05:30
it('adds a correct class to identicon', () => {
expect(wrapper.find({ ref: 'identicon' }).classes()).toContain('bg2');
});
2020-03-13 15:44:24 +05:30
});
2018-03-17 18:26:18 +05:30
2020-05-24 23:13:21 +05:30
describe('entity id is a GraphQL id', () => {
beforeEach(() => createComponent({ entityId: 'gid://gitlab/Project/8' }));
it('matches snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
2018-03-17 18:26:18 +05:30
2020-05-24 23:13:21 +05:30
it('adds a correct class to identicon', () => {
expect(wrapper.find({ ref: 'identicon' }).classes()).toContain('bg2');
});
2017-09-10 17:25:29 +05:30
});
});