Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
sommilito-bank2
/
splide-4.1.3
/
src
/
js
/
utils
/
dom
/
matches
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
import { matches } from './matches'; describe( 'children', () => { beforeEach( () => { document.body.innerHTML = ` <div id="container"> <span id="span1" class="active"></span> <button id="button1" class="active"></button> <span id="span2"></span> <button id="button2"></button> <span id="span3"></span> <button id="button3"></button> </div> `; } ); test( 'can test if the selector matches the element or not.', () => { const container = document.getElementById( 'container' ); expect( matches( container, 'div' ) ).toBe( true ); expect( matches( container, '#container' ) ).toBe( true ); expect( matches( container, 'span' ) ).toBe( false ); const span = container.firstElementChild; expect( matches( span, 'span' ) ).toBe( true ); expect( matches( span, '#span1' ) ).toBe( true ); expect( matches( span, '.active' ) ).toBe( true ); expect( matches( span, '#container .active' ) ).toBe( true ); expect( matches( span, '#container' ) ).toBe( false ); expect( matches( span, '#span2' ) ).toBe( false ); } ); } );