import SelectorEngine from '../../../src/dom/selector-engine' import { makeArray } from '../../../src/util/index' /** Test helpers */ import { getFixture, clearFixture } from '../../helpers/fixture' describe('SelectorEngine', () => { let fixtureEl beforeAll(() => { fixtureEl = getFixture() }) afterEach(() => { clearFixture() }) describe('matches', () => { it('should return matched elements', () => { fixtureEl.innerHTML = '
' expect(SelectorEngine.matches(fixtureEl, 'div')).toEqual(true) }) }) describe('find', () => { it('should find elements', () => { fixtureEl.innerHTML = '' const div = fixtureEl.querySelector('div') expect(makeArray(SelectorEngine.find('div', fixtureEl))).toEqual([div]) }) it('should find elements globaly', () => { fixtureEl.innerHTML = '' const div = fixtureEl.querySelector('#test') expect(makeArray(SelectorEngine.find('#test'))).toEqual([div]) }) it('should handle :scope selectors', () => { fixtureEl.innerHTML = `` const listEl = fixtureEl.querySelector('ul') const aActive = fixtureEl.querySelector('.active') expect(makeArray(SelectorEngine.find(':scope > li > .active', listEl))).toEqual([aActive]) }) }) describe('findOne', () => { it('should return one element', () => { fixtureEl.innerHTML = '' const div = fixtureEl.querySelector('#test') expect(SelectorEngine.findOne('#test')).toEqual(div) }) }) describe('children', () => { it('should find children', () => { fixtureEl.innerHTML = `