import React from 'react'; import { Icon, addIcon, addCollection } from '../../dist/offline'; import { describe, test, expect } from 'vitest'; import { render } from '@testing-library/react'; const iconData = { body: '', width: 24, height: 24, }; describe('Using storage', () => { test('using storage', () => { addIcon('test-icon', iconData); const renderResult = render(); expect(renderResult.container.innerHTML).toContain( 'M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z' ); }); test('using storage with icon set', () => { const iconSet = { prefix: 'mdi-light', icons: { account: { body: '', }, home: { body: '', }, }, width: 24, height: 24, }; addCollection(iconSet); const renderResult = render(); expect(renderResult.container.innerHTML).toContain( '"M11.5 14c4.142 0 7.5 1.567 7.5 3.5V20' ); }); test('using storage with icon set with custom prefix', () => { const iconSet = { prefix: 'mdi-light', icons: { 'account-alert': { body: '', }, 'link': { body: '', }, }, width: 24, height: 24, }; addCollection(iconSet, 'custom-'); const renderResult = render(); expect(renderResult.container.innerHTML).toContain( 'M8 13v-1h7v1H8zm7.5-6a5.5 5.5 0 1 1 0 11H13v-1h2.5' ); }); test('missing icon from storage', () => { const renderResult = render(); expect(renderResult.container.innerHTML).toEqual(''); }); });