diff options
Diffstat (limited to 'spec/frontend/__helpers__/vue_mock_directive.js')
-rw-r--r-- | spec/frontend/__helpers__/vue_mock_directive.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/frontend/__helpers__/vue_mock_directive.js b/spec/frontend/__helpers__/vue_mock_directive.js new file mode 100644 index 00000000000..e952f258c4d --- /dev/null +++ b/spec/frontend/__helpers__/vue_mock_directive.js @@ -0,0 +1,25 @@ +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 = () => ({ + bind(el, binding) { + writeBindingToElement(el, binding); + }, + + update(el, binding) { + writeBindingToElement(el, binding); + }, + + unbind(el, { name }) { + delete el[getKey(name)]; + }, +}); |