import mocha from 'mocha';
import chai from 'chai';
import { getNode } from './node';
import Iconify from '@iconify/iconify/lib/iconify';
const expect = chai.expect;
const selector =
'span.iconify, i.iconify, span.iconify-inline, i.iconify-inline';
// Do not observe document.body!
Iconify.stopObserving(document.body);
// Create node to observe
const observedNode = getNode('iconify-api');
const ignoredNode = getNode('iconify-api');
Iconify.observe(observedNode);
observedNode.innerHTML =
'
Testing Iconify with API (should render SVG!)
' +
'- Inline icons:' +
' ' +
' ' +
'
' +
'- Block icons:' +
' ' +
' ' +
'
' +
'
';
ignoredNode.innerHTML =
'This node should not have icons! ';
describe('Testing Iconify object with API', () => {
it('Rendering icons with API', () => {
// Icons should have been replaced by now
let list = observedNode.querySelectorAll(selector);
expect(list.length).to.be.equal(0);
list = observedNode.querySelectorAll('svg.iconify');
expect(list.length).to.be.equal(4);
// Icons in ignored node should not have been replaced
list = ignoredNode.querySelectorAll(selector);
expect(list.length).to.be.equal(1);
list = ignoredNode.querySelectorAll('svg.iconify');
expect(list.length).to.be.equal(0);
});
});