import mocha from 'mocha'; import chai from 'chai'; import { getNode } from './node'; import { addFinder } from '@iconify/iconify/lib/finder'; import { finder as iconifyFinder } from '@iconify/iconify/lib/finders/iconify'; import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconify-icon'; import { getStorage, addIconSet } from '@iconify/core/lib/storage'; import { browserModules } from '@iconify/iconify/lib/modules'; import { scanDOM } from '@iconify/iconify/lib/scanner/scan'; const expect = chai.expect; // Add finders addFinder(iconifyFinder); addFinder(iconifyIconFinder); describe('Scanning DOM', () => { // Add mentioned icons to storage const storage = getStorage('', 'mdi'); addIconSet(storage, { prefix: 'mdi', icons: { 'account-box': { body: '', }, 'account-cash': { body: '', }, 'account': { body: '', }, 'home': { body: '', }, }, width: 24, height: 24, }); it('Scan DOM with preloaded icons', () => { const node = getNode('scan-dom'); node.innerHTML = '

Testing scanning DOM

    ' + '
  • Valid icons:' + ' ' + ' ' + '
  • ' + '
  • Block icon:' + ' ' + ' ' + '
  • ' + '
'; browserModules.root = node; scanDOM(); // Find elements const elements = node.querySelectorAll('svg.iconify'); expect(elements.length).to.be.equal(4); }); });