2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-13 22:18:24 +00:00
iconify/plugins/tailwind/tests/clean-css-test.ts

69 lines
1.5 KiB
TypeScript
Raw Normal View History

import { getCSSRulesForIcons } from '../src/clean';
2023-01-11 15:42:21 +00:00
describe('Testing clean CSS rules', () => {
2023-01-11 15:42:21 +00:00
it('One icon', () => {
const data = getCSSRulesForIcons('mdi-light:home');
2023-01-11 15:42:21 +00:00
expect(Object.keys(data)).toEqual([
'.icon--mdi-light',
'.icon--mdi-light--home',
]);
expect(Object.keys(data['.icon--mdi-light--home'])).toEqual(['--svg']);
});
it('Multiple icons from same icon set', () => {
const data = getCSSRulesForIcons([
2023-01-11 15:42:21 +00:00
// By name
'mdi-light:home',
// By selector
'.icon--mdi-light--arrow-left',
'.icon--mdi-light.icon--mdi-light--arrow-down',
// By class name
'icon--mdi-light--file',
'icon--mdi-light icon--mdi-light--format-clear',
]);
expect(Object.keys(data)).toEqual([
'.icon--mdi-light',
'.icon--mdi-light--home',
'.icon--mdi-light--arrow-left',
'.icon--mdi-light--arrow-down',
'.icon--mdi-light--file',
'.icon--mdi-light--format-clear',
]);
});
it('Multiple icon sets', () => {
const data = getCSSRulesForIcons([
2023-01-11 15:42:21 +00:00
// MDI Light
'mdi-light:home',
// Line MD
'line-md:home',
]);
expect(Object.keys(data)).toEqual([
'.icon--mdi-light',
'.icon--mdi-light--home',
'.icon--line-md',
'.icon--line-md--home',
]);
});
it('Bad class name', () => {
let threw = false;
try {
getCSSRulesForIcons(['icon--mdi-light--home test']);
2023-01-11 15:42:21 +00:00
} catch {
threw = true;
}
expect(threw).toBe(true);
});
it('Bad icon set', () => {
let threw = false;
try {
getCSSRulesForIcons('test123:home');
2023-01-11 15:42:21 +00:00
} catch {
threw = true;
}
expect(threw).toBe(true);
});
});