1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/lib/markdownUtils.test.ts
Adarsh Singh f59e312ee2
Desktop: Resolves #4750 Disappearing text in markdown editor (#4781)
Fixes #4750 by preventing automatic deletion of list elements in certain cases
2021-04-01 21:39:42 -06:00

95 lines
3.3 KiB
TypeScript

import markdownUtils from './markdownUtils';
describe('Should detect list items', () => {
test('should detect `- lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('- lorem ipsum')).toBe(true);
});
test('should detect `+ lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('+ lorem ipsum')).toBe(true);
});
test('should detect `* lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('* lorem ipsum')).toBe(true);
});
// ordered list
test('should detect `1. lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('1. lorem ipsum')).toBe(true);
});
test('should detect `1) lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('1) lorem ipsum')).toBe(true);
});
// checkbox list
test('should detect `+ [x] lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('+ [x] lorem ipsum')).toBe(true);
});
// ordered list
test('should NOT detect `-lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('-lorem ipsum')).toBe(false);
});
test('should NOT detect `+lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('+lorem ipsum')).toBe(false);
});
test('should NOT detect `*lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('*lorem ipsum')).toBe(false);
});
// ordered list
test('should NOT detect `1.lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('1.lorem ipsum')).toBe(false);
});
test('should NOT detect `1)lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('1)lorem ipsum')).toBe(false);
});
test('should NOT detect `+[x]lorem ipsum` as list item ', () => {
expect(markdownUtils.isListItem('+[x]lorem ipsum')).toBe(false);
});
// Empty list detection
test('should detect `- ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('- ')).toBe(true);
});
test('should detect `+ ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('+ ')).toBe(true);
});
test('should detect `* ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('* ')).toBe(true);
});
// ordered list
test('should detect `1. ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('1. ')).toBe(true);
});
test('should detect `1) ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('1) ')).toBe(true);
});
// checkbox list
test('should detect `+ [x] ` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('+ [x] ')).toBe(true);
});
// unordered list
test('should NOT detect `-` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('-')).toBe(false);
});
test('should NOT detect `+` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('+')).toBe(false);
});
test('should NOT detect `*` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('*')).toBe(false);
});
// ordered list
test('should NOT detect `1.` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('1.')).toBe(false);
});
test('should NOT detect `1)` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('1)')).toBe(false);
});
// checbox list
test('should NOT detect `+ [x]` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('+ [x]')).toBe(false);
});
});