UNPKG

@glidejs/glide

Version:

Glide.js is a dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

31 lines (25 loc) 909 B
import { exist, toArray, siblings } from '../../src/utils/dom' describe('Function', () => { beforeEach(() => { document.body.innerHTML = ` <div class="parent"> <div class="child"></div> <div class="child"></div> <div class="child"></div> </div> ` }) test('`siblings` should return siblings of the passed HTMLElements', () => { let children = document.querySelectorAll('.child') expect(siblings(children[1])).toHaveLength(2) }) test('`toArray` should return an array with the same elements when passed a NodeList', () => { let children = document.querySelectorAll('.child') // eslint-disable-next-line no-undef expect(NodeList.prototype.isPrototypeOf(children)).toBe(true) expect(Array.isArray(toArray(children))).toBe(true) toArray(children).forEach((child, i) => { expect(child).toEqual(children[i]) }) }) })