2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-05 12:57:53 +00:00
iconify/plugins/tailwind/tests/get-css-test.ts

69 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-01-11 15:42:21 +00:00
import { getCSSRules } from '../src/iconify';
describe('Testing CSS rules', () => {
it('One icon', () => {
const data = getCSSRules('mdi-light:home');
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 = getCSSRules([
// 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 = getCSSRules([
// 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 {
getCSSRules(['icon--mdi-light--home test']);
} catch {
threw = true;
}
expect(threw).toBe(true);
});
it('Bad icon set', () => {
let threw = false;
try {
getCSSRules('test123:home');
} catch {
threw = true;
}
expect(threw).toBe(true);
});
});