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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import { GlAvatarLabeled } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import OrganizationsListItem from '~/organizations/index/components/organizations_list_item.vue';
import { organizations } from '~/organizations/mock_data';
const MOCK_ORGANIZATION = organizations[0];
describe('OrganizationsListItem', () => {
let wrapper;
const defaultProps = {
organization: MOCK_ORGANIZATION,
};
const createComponent = (props = {}) => {
wrapper = shallowMountExtended(OrganizationsListItem, {
propsData: {
...defaultProps,
...props,
},
});
};
const findGlAvatarLabeled = () => wrapper.findComponent(GlAvatarLabeled);
const findHTMLOrganizationDescription = () =>
wrapper.findByTestId('organization-description-html');
describe('template', () => {
beforeEach(() => {
createComponent();
});
it('renders GlAvatarLabeled with correct data', () => {
expect(findGlAvatarLabeled().attributes()).toMatchObject({
'entity-id': getIdFromGraphQLId(MOCK_ORGANIZATION.id).toString(),
'entity-name': MOCK_ORGANIZATION.name,
src: MOCK_ORGANIZATION.avatarUrl,
label: MOCK_ORGANIZATION.name,
labellink: MOCK_ORGANIZATION.webUrl,
});
});
});
describe('organization description', () => {
const descriptionHtml = '<p>Foo bar</p>';
describe('is a HTML description', () => {
beforeEach(() => {
createComponent({ organization: { ...MOCK_ORGANIZATION, descriptionHtml } });
});
it('renders HTML description', () => {
expect(findHTMLOrganizationDescription().html()).toContain(descriptionHtml);
});
});
describe('is not a HTML description', () => {
beforeEach(() => {
createComponent({
organization: { ...MOCK_ORGANIZATION, descriptionHtml: null },
});
});
it('does not render HTML description', () => {
expect(findHTMLOrganizationDescription().exists()).toBe(false);
});
});
});
});
|