2020-01-23 13:08:53 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import IdenticonComponent from '~/vue_shared/components/identicon.vue';
|
|
|
|
|
|
|
|
describe('Identicon', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2020-05-18 08:08:08 -04:00
|
|
|
const defaultProps = {
|
|
|
|
entityId: 1,
|
|
|
|
entityName: 'entity-name',
|
|
|
|
sizeClass: 's40',
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
2020-01-23 13:08:53 -05:00
|
|
|
wrapper = shallowMount(IdenticonComponent, {
|
|
|
|
propsData: {
|
2020-05-18 08:08:08 -04:00
|
|
|
...defaultProps,
|
|
|
|
...props,
|
2020-01-23 13:08:53 -05:00
|
|
|
},
|
2017-08-01 05:08:09 -04:00
|
|
|
});
|
2020-01-23 13:08:53 -05:00
|
|
|
};
|
2017-08-01 05:08:09 -04:00
|
|
|
|
2020-01-23 13:08:53 -05:00
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2017-08-01 05:08:09 -04:00
|
|
|
});
|
|
|
|
|
2020-05-18 08:08:08 -04:00
|
|
|
describe('entity id is a number', () => {
|
|
|
|
beforeEach(createComponent);
|
|
|
|
|
|
|
|
it('matches snapshot', () => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
2017-09-04 11:42:27 -04:00
|
|
|
|
2020-05-18 08:08:08 -04:00
|
|
|
it('adds a correct class to identicon', () => {
|
|
|
|
expect(wrapper.find({ ref: 'identicon' }).classes()).toContain('bg2');
|
|
|
|
});
|
2020-01-23 13:08:53 -05:00
|
|
|
});
|
2017-09-04 11:42:27 -04:00
|
|
|
|
2020-05-18 08:08:08 -04:00
|
|
|
describe('entity id is a GraphQL id', () => {
|
|
|
|
beforeEach(() => createComponent({ entityId: 'gid://gitlab/Project/8' }));
|
|
|
|
|
|
|
|
it('matches snapshot', () => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
2017-09-04 11:42:27 -04:00
|
|
|
|
2020-05-18 08:08:08 -04:00
|
|
|
it('adds a correct class to identicon', () => {
|
|
|
|
expect(wrapper.find({ ref: 'identicon' }).classes()).toContain('bg2');
|
|
|
|
});
|
2017-08-01 05:08:09 -04:00
|
|
|
});
|
|
|
|
});
|