decap-cms-editor-component-image
Version:
Image component for Decap CMS editor widget
76 lines (58 loc) • 2.34 kB
JavaScript
import component from '../index';
function getAsset(path) {
return path;
}
const image = '/image';
const alt = 'alt';
const title = 'title';
describe('editor component image', () => {
it('should generate empty markdown image from empty object', () => {
expect(component.toBlock({})).toEqual(`![]()`);
});
it('should generate valid markdown from path', () => {
expect(component.toBlock({ image })).toEqual(``);
});
it('should generate valid markdown from path and alt text', () => {
expect(component.toBlock({ image, alt })).toEqual(``);
});
it('should generate valid markdown from path and title', () => {
expect(component.toBlock({ image, title })).toEqual(``);
});
it('should generate valid markdown from path, alt text, and title ', () => {
expect(component.toBlock({ image, alt, title })).toEqual(``);
});
it('should escape quotes in title', () => {
expect(component.toBlock({ image, alt, title: `"ti"tle"` })).toEqual(
``,
);
});
it('should generate valid react props', () => {
expect(component.toPreview({ image, alt, title }, getAsset)).toMatchObject({
props: { src: image, alt, title },
});
});
it('should match markdown with no properties defined', () => {
expect(`![]()`).toMatch(component.pattern);
});
it('should match markdown with path', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with path and alt text', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with path and title', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with path, alt text, and title', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with path, alt text, and title', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with arbitrary amount of whitespace', () => {
expect(``).toMatch(component.pattern);
});
it('should match markdown with quoted title', () => {
expect(``).toMatch(component.pattern);
});
});