Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dl_locator_helper.js « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b507dcd599d5dc40d166da7853368272319071ba (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
import { createWrapper, ErrorWrapper } from '@vue/test-utils';

/**
 * Find the definition (<dd>) that corresponds to this term (<dt>)
 *
 * Given html in the `wrapper`:
 *
 * <dl>
 *   <dt>My label</dt>
 *   <dd>Value</dd>
 * </dl>
 *
 * findDd('My label', wrapper)
 *
 * Returns `<dd>Value</dd>`
 *
 * @param {object} wrapper - Parent wrapper
 * @param {string} dtLabel - Label for this value
 * @returns Wrapper
 */
export const findDd = (dtLabel, wrapper) => {
  const dt = wrapper.findByText(dtLabel).element;
  const dd = dt.nextElementSibling;
  if (dt.tagName === 'DT' && dd.tagName === 'DD') {
    return createWrapper(dd, {});
  }
  return ErrorWrapper(dtLabel);
};