|
| 1 | +import { expect } from '@open-wc/testing'; |
| 2 | +import { ufm } from './marked-ufm.plugin.js'; |
| 3 | +import { UmbMarked } from '../index.js'; |
| 4 | +import { UmbUfmLabelValueComponent } from '../ufm-components/label-value.component.js'; |
| 5 | +import { UmbUfmLocalizeComponent } from '../ufm-components/localize.component.js'; |
| 6 | + |
| 7 | +describe('UmbMarkedUfm', () => { |
| 8 | + describe('UFM parsing', () => { |
| 9 | + const runs = [ |
| 10 | + { ufm: '{=prop1}', expected: '<ufm-label-value alias="prop1"></ufm-label-value>' }, |
| 11 | + { ufm: '{= prop1}', expected: '<ufm-label-value alias="prop1"></ufm-label-value>' }, |
| 12 | + { ufm: '{= prop1 }', expected: '<ufm-label-value alias="prop1"></ufm-label-value>' }, |
| 13 | + { ufm: '{{=prop1}}', expected: '{<ufm-label-value alias="prop1"></ufm-label-value>}' }, |
| 14 | + { ufm: '{#general_add}', expected: '<umb-localize key="general_add"></umb-localize>' }, |
| 15 | + ]; |
| 16 | + |
| 17 | + // Manually configuring the UFM components for testing. |
| 18 | + UmbMarked.use( |
| 19 | + ufm([ |
| 20 | + { alias: 'Umb.Markdown.LabelValue', marker: '=', render: new UmbUfmLabelValueComponent().render }, |
| 21 | + { alias: 'Umb.Markdown.Localize', marker: '#', render: new UmbUfmLocalizeComponent().render }, |
| 22 | + ]), |
| 23 | + ); |
| 24 | + |
| 25 | + runs.forEach((run) => { |
| 26 | + it(`Parsing "${run.ufm}"`, async () => { |
| 27 | + const markup = await UmbMarked.parseInline(run.ufm); |
| 28 | + expect(markup).to.equal(run.expected); |
| 29 | + }); |
| 30 | + }); |
| 31 | + }); |
| 32 | +}); |
0 commit comments