import mocha from 'mocha'; import chai from 'chai'; import { getNode } from './node'; import { addFinder, findPlaceholders, } from '@iconify/iconify/lib/modules/finder'; import { IconifyFinder } from '@iconify/iconify/lib/finders/interface'; import { finder as iconifyFinder } from '@iconify/iconify/lib/finders/iconify'; import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconify-icon'; import { IconifyIconName } from '@iconify/core/lib/icon/name'; const expect = chai.expect; // Add finders addFinder(iconifyFinder); addFinder(iconifyIconFinder); describe('Testing finder', () => { it('Finding nodes', () => { const node = getNode('finder'); node.innerHTML = '

List of icons

'; const items = findPlaceholders(node); function testIcon( name: IconifyIconName | null, expectedFinder: IconifyFinder ): void { const item = items.shift(); expect(item.name).to.be.eql(name); expect(item.finder).to.be.equal(expectedFinder); } // Test all icons testIcon( { provider: '', prefix: 'mdi', name: 'home', }, iconifyFinder ); testIcon( { provider: '', prefix: 'mdi', name: 'account', }, iconifyFinder ); testIcon( { provider: '', prefix: 'ic', name: 'baseline-account', }, iconifyIconFinder ); // End of list expect(items.shift()).to.be.equal(void 0); }); });