blob: a0a77766872ffaafb0ca8eaba99f8f843723587c (
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
|
import { createWrapper } from '@vue/test-utils';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import initGitlabVersionCheck from '~/gitlab_version_check';
import {
VERSION_CHECK_BADGE_NO_PROP_FIXTURE,
VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE,
VERSION_CHECK_BADGE_FIXTURE,
} from './mock_data';
describe('initGitlabVersionCheck', () => {
let vueApps;
const createApp = (fixture) => {
setHTMLFixture(fixture);
vueApps = initGitlabVersionCheck();
};
afterEach(() => {
resetHTMLFixture();
});
describe.each`
description | fixture | badgeTexts
${'with no version check badge el'} | ${'<div></div>'} | ${[]}
${'with version check badge el but no prop data'} | ${VERSION_CHECK_BADGE_NO_PROP_FIXTURE} | ${[undefined]}
${'with version check badge el but no severity data'} | ${VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE} | ${[undefined]}
${'with version check badge el and version data'} | ${VERSION_CHECK_BADGE_FIXTURE} | ${['Up to date']}
`('$description', ({ fixture, badgeTexts }) => {
beforeEach(() => {
createApp(fixture);
});
it(`correctly renders the Version Check Badge`, () => {
const vueAppInstances = vueApps.map((v) => v && createWrapper(v));
const renderedBadgeTexts = vueAppInstances.map((i) => i?.text());
expect(renderedBadgeTexts).toStrictEqual(badgeTexts);
});
});
});
|