mirror of
https://github.com/iconify/iconify.git
synced 2024-12-13 14:13:06 +00:00
Update browser tests
This commit is contained in:
parent
f3dffba74f
commit
5a26c44009
@ -3,7 +3,7 @@ import chai from 'chai';
|
||||
|
||||
import { FakeData, setFakeData, prepareQuery, sendQuery } from './fake-api';
|
||||
import { setAPIModule } from '@iconify/core/lib/api/modules';
|
||||
import { setAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { addAPIProvider } from '@iconify/core/lib/api/config';
|
||||
import { loadIcons } from '@iconify/core/lib/api/icons';
|
||||
|
||||
const expect = chai.expect;
|
||||
@ -40,7 +40,7 @@ describe('Testing fake API', () => {
|
||||
height: 24,
|
||||
},
|
||||
};
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
setFakeData(provider, prefix, data);
|
||||
@ -89,7 +89,7 @@ describe('Testing fake API', () => {
|
||||
height: 24,
|
||||
},
|
||||
};
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
setFakeData(provider, prefix, data);
|
||||
@ -147,7 +147,7 @@ describe('Testing fake API', () => {
|
||||
height: 24,
|
||||
},
|
||||
};
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
rotate: 20,
|
||||
timeout: 100,
|
||||
|
@ -11,9 +11,9 @@ import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconif
|
||||
import {
|
||||
getStorage,
|
||||
addIconSet,
|
||||
getIcon,
|
||||
getIconFromStorage,
|
||||
} from '@iconify/core/lib/storage/storage';
|
||||
import { renderIcon } from '@iconify/iconify/lib/modules/render';
|
||||
import { renderIconInPlaceholder } from '@iconify/iconify/lib/modules/render';
|
||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||
import { IconifyElement } from '@iconify/iconify/lib/modules/element';
|
||||
|
||||
@ -101,11 +101,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -146,11 +146,15 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -190,11 +194,15 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -236,11 +244,15 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -278,11 +290,15 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -327,11 +343,15 @@ describe('Testing legacy renderer', () => {
|
||||
element.element.style.border = '1px solid green';
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -398,11 +418,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -452,10 +472,14 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test attributes, compare them with last SVG
|
||||
@ -517,10 +541,14 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test changed attributes
|
||||
@ -564,10 +592,14 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test changed attributes
|
||||
@ -610,11 +642,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -659,11 +691,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -706,7 +738,7 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
expect(iconData.body.indexOf('M6 17c0-2')).to.be.equal(
|
||||
-1,
|
||||
@ -714,7 +746,7 @@ describe('Testing legacy renderer', () => {
|
||||
);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -748,7 +780,7 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Test icon body to make sure icon was changed
|
||||
@ -757,7 +789,11 @@ describe('Testing legacy renderer', () => {
|
||||
'Wrong icon body: ' + iconData.body
|
||||
);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test finder
|
||||
@ -794,16 +830,16 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
let html = renderIcon(
|
||||
let html = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData,
|
||||
@ -844,13 +880,22 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
html = renderIcon(element, customisations, iconData, true) as string;
|
||||
html = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData,
|
||||
true
|
||||
) as string;
|
||||
|
||||
// Test icon body to make sure icon was changed
|
||||
expect(html.indexOf('transform="')).to.not.be.equal(
|
||||
@ -892,11 +937,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -934,10 +979,14 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Check dimensions
|
||||
@ -980,11 +1029,11 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -1028,10 +1077,14 @@ describe('Testing legacy renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Check dimensions and alignment
|
||||
|
@ -11,9 +11,9 @@ import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconif
|
||||
import {
|
||||
getStorage,
|
||||
addIconSet,
|
||||
getIcon,
|
||||
getIconFromStorage,
|
||||
} from '@iconify/core/lib/storage/storage';
|
||||
import { renderIcon } from '@iconify/iconify/lib/modules/render';
|
||||
import { renderIconInPlaceholder } from '@iconify/iconify/lib/modules/render';
|
||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||
import { IconifyElement } from '@iconify/iconify/lib/modules/element';
|
||||
|
||||
@ -101,11 +101,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -146,11 +146,15 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -190,11 +194,15 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -236,11 +244,15 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -278,11 +290,15 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -329,11 +345,15 @@ describe('Testing renderer', () => {
|
||||
element.element.style.border = '1px solid green';
|
||||
|
||||
// Get icon data
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
|
||||
// Test SVG
|
||||
expect(svg.tagName.toUpperCase()).to.be.equal('SVG');
|
||||
@ -400,11 +420,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -456,10 +476,14 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test attributes, compare them with last SVG
|
||||
@ -521,10 +545,14 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test changed attributes
|
||||
@ -568,10 +596,14 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test changed attributes
|
||||
@ -614,11 +646,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -663,11 +695,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -710,7 +742,7 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
expect(iconData.body.indexOf('M6 17c0-2')).to.be.equal(
|
||||
-1,
|
||||
@ -718,7 +750,7 @@ describe('Testing renderer', () => {
|
||||
);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -752,7 +784,7 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Test icon body to make sure icon was changed
|
||||
@ -761,7 +793,11 @@ describe('Testing renderer', () => {
|
||||
'Wrong icon body: ' + iconData.body
|
||||
);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Test finder
|
||||
@ -798,16 +834,16 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
let html = renderIcon(
|
||||
let html = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData,
|
||||
@ -848,13 +884,22 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
html = renderIcon(element, customisations, iconData, true) as string;
|
||||
html = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData,
|
||||
true
|
||||
) as string;
|
||||
|
||||
// Test icon body to make sure icon was changed
|
||||
expect(html.indexOf('transform="')).to.not.be.equal(
|
||||
@ -896,11 +941,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -938,10 +983,14 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Check dimensions
|
||||
@ -984,11 +1033,11 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data
|
||||
let iconData = getIcon(storage, element.name.name);
|
||||
let iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
// Render icon
|
||||
let svg = renderIcon(
|
||||
let svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
@ -1032,10 +1081,14 @@ describe('Testing renderer', () => {
|
||||
});
|
||||
|
||||
// Get icon data and render SVG
|
||||
iconData = getIcon(storage, element.name.name);
|
||||
iconData = getIconFromStorage(storage, element.name.name);
|
||||
expect(iconData).to.not.be.equal(null);
|
||||
|
||||
svg = renderIcon(element, customisations, iconData) as IconifyElement;
|
||||
svg = renderIconInPlaceholder(
|
||||
element,
|
||||
customisations,
|
||||
iconData
|
||||
) as IconifyElement;
|
||||
expect(svg).to.not.be.eql(lastSVG);
|
||||
|
||||
// Check dimensions and alignment
|
||||
|
@ -8,7 +8,6 @@ import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconif
|
||||
import { getStorage, addIconSet } from '@iconify/core/lib/storage/storage';
|
||||
import { listRootNodes } from '@iconify/iconify/lib/modules/root';
|
||||
import { scanDOM, scanElement } from '@iconify/iconify/lib/modules/scanner';
|
||||
import { removeObservedNode } from '@iconify/iconify/lib/modules/observer';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
|
@ -10,8 +10,8 @@ import { listRootNodes } from '@iconify/iconify/lib/modules/root';
|
||||
import { scanDOM } from '@iconify/iconify/lib/modules/scanner';
|
||||
import {
|
||||
initObserver,
|
||||
observeNode,
|
||||
removeObservedNode,
|
||||
observe,
|
||||
stopObserving,
|
||||
} from '@iconify/iconify/lib/modules/observer';
|
||||
|
||||
const expect = chai.expect;
|
||||
@ -141,7 +141,7 @@ describe('Observe DOM', () => {
|
||||
expect(nodes[0].temporary).to.be.equal(false);
|
||||
|
||||
// Observe another node
|
||||
observeNode(node);
|
||||
observe(node);
|
||||
|
||||
nodes = listRootNodes();
|
||||
expect(nodes.length).to.be.equal(2);
|
||||
@ -200,7 +200,7 @@ describe('Observe DOM', () => {
|
||||
'<span class="iconify" data-icon="mdi:home"></span>';
|
||||
|
||||
// Observe node: should run scan on next tick
|
||||
observeNode(node);
|
||||
observe(node);
|
||||
|
||||
// Test nodes
|
||||
setTimeout(() => {
|
||||
@ -236,7 +236,7 @@ describe('Observe DOM', () => {
|
||||
expect(nodes[0].temporary).to.be.equal(false);
|
||||
|
||||
// Observe another node
|
||||
observeNode(node);
|
||||
observe(node);
|
||||
|
||||
nodes = listRootNodes();
|
||||
expect(nodes.length).to.be.equal(2);
|
||||
@ -246,7 +246,7 @@ describe('Observe DOM', () => {
|
||||
expect(nodes[1].temporary).to.be.equal(false);
|
||||
|
||||
// Stop observing baseNode
|
||||
removeObservedNode(baseNode);
|
||||
stopObserving(baseNode);
|
||||
|
||||
nodes = listRootNodes();
|
||||
expect(nodes.length).to.be.equal(1);
|
||||
|
@ -5,7 +5,7 @@ import { getNode, setRoot } from './node';
|
||||
import { addFinder } from '@iconify/iconify/lib/modules/finder';
|
||||
import { FakeData, setFakeData, prepareQuery, sendQuery } from './fake-api';
|
||||
import { setAPIModule } from '@iconify/core/lib/api/modules';
|
||||
import { setAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { addAPIProvider } from '@iconify/core/lib/api/config';
|
||||
import { finder as iconifyFinder } from '@iconify/iconify/lib/finders/iconify';
|
||||
import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconify-icon';
|
||||
import { listRootNodes } from '@iconify/iconify/lib/modules/root';
|
||||
@ -37,7 +37,7 @@ describe('Scanning DOM with API', () => {
|
||||
const prefix2 = nextPrefix();
|
||||
|
||||
// Set fake API hosts to make test reliable
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
|
||||
@ -146,7 +146,7 @@ describe('Scanning DOM with API', () => {
|
||||
const prefix2 = nextPrefix();
|
||||
|
||||
// Set fake API hosts to make test reliable
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
|
||||
@ -295,7 +295,7 @@ describe('Scanning DOM with API', () => {
|
||||
const prefix2 = nextPrefix();
|
||||
|
||||
// Set fake API hosts to make test reliable
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
|
||||
@ -396,7 +396,7 @@ describe('Scanning DOM with API', () => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
// Set fake API hosts to make test reliable
|
||||
setAPIConfig(provider, {
|
||||
addAPIProvider(provider, {
|
||||
resources: ['https://api1.local', 'https://api2.local'],
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { addRootNode, listRootNodes } from '@iconify/iconify/lib/modules/root';
|
||||
import { removeObservedNode } from '@iconify/iconify/lib/modules/observer';
|
||||
import { stopObserving } from '@iconify/iconify/lib/modules/observer';
|
||||
import { ObservedNode } from '@iconify/iconify/lib/modules/observed-node';
|
||||
|
||||
let counter = 0;
|
||||
@ -23,7 +23,7 @@ export function getNode(prefix = 'test') {
|
||||
export function setRoot(node: HTMLElement): ObservedNode {
|
||||
listRootNodes().forEach((node) => {
|
||||
if (typeof node.node !== 'function') {
|
||||
removeObservedNode(node.node);
|
||||
stopObserving(node.node);
|
||||
}
|
||||
});
|
||||
return addRootNode(node);
|
||||
|
Loading…
Reference in New Issue
Block a user