Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2020-04-29 07:57:08 +0300
committerPaul Slaughter <pslaughter@gitlab.com>2020-05-20 01:06:11 +0300
commit26bb98496b060ef60d6edc265fa7a12ee9d612a4 (patch)
treeadb7f036b85683099bca6a23d3d76ee06ec1396b /spec/frontend/shared/dom_spec.js
parenta61458419fe97029cc9d1c198bd313dd6af548b6 (diff)
Create Vue table_of_contents
Also: - Updates toc.scss to look for .table-of-contents - Creates some dom helpers in shared - Stick to footer directive - Moves toc collapse button to component - Fixes issue where collapsed on mobile affects full view
Diffstat (limited to 'spec/frontend/shared/dom_spec.js')
-rw-r--r--spec/frontend/shared/dom_spec.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/frontend/shared/dom_spec.js b/spec/frontend/shared/dom_spec.js
new file mode 100644
index 00000000..ceb09708
--- /dev/null
+++ b/spec/frontend/shared/dom_spec.js
@@ -0,0 +1,32 @@
+import { findChildByTagName } from '../../../content/frontend/shared/dom';
+
+describe('frontend/shared/dom', () => {
+ const createElementWithChildren = children => {
+ const el = document.createElement('div');
+
+ children.forEach(tag => {
+ const child = document.createElement(tag);
+ el.appendChild(child);
+ });
+
+ return el;
+ };
+
+ describe('findChildByTagName', () => {
+ it.each`
+ children | tagName | expectedIndex
+ ${['div', 'p', 'ul', 'p']} | ${'p'} | ${1}
+ ${['div', 'ul']} | ${'p'} | ${-1}
+ ${['li', 'li', 'li']} | ${'li'} | ${0}
+ ${[]} | ${'li'} | ${-1}
+ `(
+ 'with children $children and $tagName, returns $expectedIndex child',
+ ({ children, tagName, expectedIndex }) => {
+ const el = createElementWithChildren(children);
+ const expectedChild = el.childNodes[expectedIndex];
+
+ expect(findChildByTagName(el, tagName)).toBe(expectedChild);
+ },
+ );
+ });
+});