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
|
export const getKey = (name) => `$_gl_jest_${name}`;
export const getBinding = (el, name) => el[getKey(name)];
const writeBindingToElement = (el, name, { value, arg, modifiers }) => {
el[getKey(name)] = {
value,
arg,
modifiers,
};
};
export const createMockDirective = (name) => {
if (!name) {
throw new Error(
'Vue 3 no longer passes the name of the directive to its hooks, an explicit name is required',
);
}
return {
bind(el, binding) {
writeBindingToElement(el, name, binding);
},
update(el, binding) {
writeBindingToElement(el, name, binding);
},
unbind(el) {
delete el[getKey(name)];
},
};
};
|