2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-10 07:11:00 +00:00
iconify/plugins/tailwind/tests/dynamic-css-test.ts
Vjacheslav Trushkin 2841b3ff05 feat(tailwind): new version with dynamic icons
BREAKING CHANGE: plugin uses named exports now, see README.md for usage
2023-01-12 20:02:54 +02:00

60 lines
1.3 KiB
TypeScript

import { getDynamicCSSRules } from '../src/dynamic';
describe('Testing dynamic CSS rules', () => {
it('One icon', () => {
const data = getDynamicCSSRules('mdi-light--home');
expect(typeof data['--svg']).toBe('string');
expect(data).toEqual({
'display': 'inline-block',
'width': '1em',
'height': '1em',
'background-color': 'currentColor',
'-webkit-mask': 'no-repeat center / 100%',
'mask': 'no-repeat center / 100%',
'-webkit-mask-image': 'var(--svg)',
'mask-image': 'var(--svg)',
'--svg': data['--svg'],
});
});
it('Only selectors that override icon', () => {
const data = getDynamicCSSRules('mdi-light--home', {
overrideOnly: true,
});
expect(typeof data['--svg']).toBe('string');
expect(data).toEqual({
'--svg': data['--svg'],
});
});
it('Missing icon', () => {
let threw = false;
try {
getDynamicCSSRules('mdi-light--missing-icon-name');
} catch {
threw = true;
}
expect(threw).toBe(true);
});
it('Bad icon name', () => {
let threw = false;
try {
getDynamicCSSRules('mdi-home');
} catch {
threw = true;
}
expect(threw).toBe(true);
});
it('Bad icon set', () => {
let threw = false;
try {
getDynamicCSSRules('test123:home');
} catch {
threw = true;
}
expect(threw).toBe(true);
});
});