blob: 5bd4bab25af651b7eed8f33867832700c4ca0fdd (
plain)
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
|
import { GlButton } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import Button from '~/ci_secure_files/components/metadata/button.vue';
import { secureFiles } from '../../mock_data';
const secureFileWithoutMetadata = secureFiles[0];
const secureFileWithMetadata = secureFiles[2];
const modalId = 'metadataModalId';
describe('Secure File Metadata Button', () => {
let wrapper;
const findButton = () => wrapper.findComponent(GlButton);
const createWrapper = (secureFile = {}, admin = false) => {
wrapper = mount(Button, {
propsData: {
admin,
modalId,
secureFile,
},
});
};
describe('metadata button visibility', () => {
it.each`
visibility | admin | fileName
${true} | ${true} | ${secureFileWithMetadata}
${false} | ${false} | ${secureFileWithMetadata}
${false} | ${false} | ${secureFileWithoutMetadata}
${false} | ${false} | ${secureFileWithoutMetadata}
`(
'button visibility is $visibility when admin equals $admin and $fileName.name is suppled',
({ visibility, admin, fileName }) => {
createWrapper(fileName, admin);
expect(findButton().exists()).toBe(visibility);
if (visibility) {
expect(findButton().isVisible()).toBe(true);
expect(findButton().attributes('aria-label')).toBe('View File Metadata');
}
},
);
});
});
|