diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2018-06-21 12:22:40 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-06-21 12:22:40 +0000 |
commit | 3e66795ef1ff1228906239763910b051d8afcc37 (patch) | |
tree | df6424d9ec008f5d1da455f8465681b371c4a11e /spec/javascripts/matchers.js | |
parent | 14e35ac9b19d358d84e0cfd167f74036937285b6 (diff) | |
download | gitlab-ce-3e66795ef1ff1228906239763910b051d8afcc37.tar.gz |
Changes tab VUE refactoring
Diffstat (limited to 'spec/javascripts/matchers.js')
-rw-r--r-- | spec/javascripts/matchers.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/javascripts/matchers.js b/spec/javascripts/matchers.js index 7cc5e753c22..0d465510fd3 100644 --- a/spec/javascripts/matchers.js +++ b/spec/javascripts/matchers.js @@ -1,4 +1,16 @@ export default { + toContainText: () => ({ + compare(vm, text) { + if (!(vm.$el instanceof HTMLElement)) { + throw new Error('vm.$el is not a DOM element!'); + } + + const result = { + pass: vm.$el.innerText.includes(text), + }; + return result; + }, + }), toHaveSpriteIcon: () => ({ compare(element, iconName) { if (!iconName) { @@ -10,7 +22,9 @@ export default { } const iconReferences = [].slice.apply(element.querySelectorAll('svg use')); - const matchingIcon = iconReferences.find(reference => reference.getAttribute('xlink:href').endsWith(`#${iconName}`)); + const matchingIcon = iconReferences.find(reference => + reference.getAttribute('xlink:href').endsWith(`#${iconName}`), + ); const result = { pass: !!matchingIcon, }; @@ -20,7 +34,7 @@ export default { } else { result.message = `${element.outerHTML} does not contain the sprite icon "${iconName}"!`; - const existingIcons = iconReferences.map((reference) => { + const existingIcons = iconReferences.map(reference => { const iconUrl = reference.getAttribute('xlink:href'); return `"${iconUrl.replace(/^.+#/, '')}"`; }); @@ -32,4 +46,12 @@ export default { return result; }, }), + toRender: () => ({ + compare(vm) { + const result = { + pass: vm.$el.nodeType !== Node.COMMENT_NODE, + }; + return result; + }, + }), }; |