blob: 591c034be9b168d675dde5f6eab1a3a1e2ef50a9 (
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
|
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 dtw = wrapper.findByText(dtLabel);
if (dtw.exists()) {
const dt = dtw.element;
const dd = dt.nextElementSibling;
if (dt.tagName === 'DT' && dd.tagName === 'DD') {
return createWrapper(dd, {});
}
}
return new ErrorWrapper(dtLabel);
};
|