debian-mirror-gitlab/spec/frontend/gitlab_version_check/index_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
3.5 KiB
JavaScript
Raw Normal View History

2023-03-04 22:38:38 +05:30
import { createWrapper } from '@vue/test-utils';
2023-01-13 00:05:48 +05:30
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import initGitlabVersionCheck from '~/gitlab_version_check';
2023-03-04 22:38:38 +05:30
import {
VERSION_CHECK_BADGE_NO_PROP_FIXTURE,
VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE,
VERSION_CHECK_BADGE_FIXTURE,
VERSION_CHECK_BADGE_FINDER,
VERSION_BADGE_TEXT,
SECURITY_PATCH_FIXTURE,
SECURITY_PATCH_FINDER,
SECURITY_PATCH_TEXT,
SECURITY_MODAL_FIXTURE,
SECURITY_MODAL_FINDER,
SECURITY_MODAL_TEXT,
} from './mock_data';
2023-01-13 00:05:48 +05:30
describe('initGitlabVersionCheck', () => {
2023-03-04 22:38:38 +05:30
let wrapper;
2023-01-13 00:05:48 +05:30
2023-03-04 22:38:38 +05:30
const createApp = (fixture) => {
setHTMLFixture(fixture);
initGitlabVersionCheck();
wrapper = createWrapper(document.body);
2023-01-13 00:05:48 +05:30
};
afterEach(() => {
resetHTMLFixture();
});
describe.each`
2023-03-04 22:38:38 +05:30
description | fixture | finders | componentTexts
${'with no version check elements'} | ${'<div></div>'} | ${[]} | ${[]}
${'with version check badge el but no prop data'} | ${VERSION_CHECK_BADGE_NO_PROP_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
${'with version check badge el but no severity data'} | ${VERSION_CHECK_BADGE_NO_SEVERITY_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[undefined]}
${'with version check badge el and version data'} | ${VERSION_CHECK_BADGE_FIXTURE} | ${[VERSION_CHECK_BADGE_FINDER]} | ${[VERSION_BADGE_TEXT]}
${'with security patch el'} | ${SECURITY_PATCH_FIXTURE} | ${[SECURITY_PATCH_FINDER]} | ${[SECURITY_PATCH_TEXT]}
${'with security patch and version badge els'} | ${`${SECURITY_PATCH_FIXTURE}${VERSION_CHECK_BADGE_FIXTURE}`} | ${[SECURITY_PATCH_FINDER, VERSION_CHECK_BADGE_FINDER]} | ${[SECURITY_PATCH_TEXT, VERSION_BADGE_TEXT]}
${'with security modal el'} | ${SECURITY_MODAL_FIXTURE} | ${[SECURITY_MODAL_FINDER]} | ${[SECURITY_MODAL_TEXT]}
${'with security modal, security patch, and version badge els'} | ${`${SECURITY_PATCH_FIXTURE}${SECURITY_MODAL_FIXTURE}${VERSION_CHECK_BADGE_FIXTURE}`} | ${[SECURITY_PATCH_FINDER, SECURITY_MODAL_FINDER, VERSION_CHECK_BADGE_FINDER]} | ${[SECURITY_PATCH_TEXT, SECURITY_MODAL_TEXT, VERSION_BADGE_TEXT]}
`('$description', ({ fixture, finders, componentTexts }) => {
beforeEach(() => {
createApp(fixture);
});
it(`correctly renders the Version Check Components`, () => {
const renderedComponentTexts = finders.map((f) => wrapper.find(f)?.element?.innerText.trim());
expect(renderedComponentTexts).toStrictEqual(componentTexts);
2023-01-13 00:05:48 +05:30
});
});
});