2020-12-23 16:10:24 -05:00
|
|
|
export const getKey = (name) => `$_gl_jest_${name}`;
|
2020-05-21 11:08:18 -04:00
|
|
|
|
|
|
|
export const getBinding = (el, name) => el[getKey(name)];
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
const writeBindingToElement = (el, { name, value, arg, modifiers }) => {
|
|
|
|
el[getKey(name)] = {
|
|
|
|
value,
|
|
|
|
arg,
|
|
|
|
modifiers,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-05-21 11:08:18 -04:00
|
|
|
export const createMockDirective = () => ({
|
2020-06-24 14:09:03 -04:00
|
|
|
bind(el, binding) {
|
|
|
|
writeBindingToElement(el, binding);
|
|
|
|
},
|
|
|
|
|
|
|
|
update(el, binding) {
|
|
|
|
writeBindingToElement(el, binding);
|
2020-05-21 11:08:18 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
unbind(el, { name }) {
|
|
|
|
delete el[getKey(name)];
|
|
|
|
},
|
|
|
|
});
|