1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-03 08:35:29 +02:00
joplin/packages/lib/markdownUtils.test.ts
Laurent Cozic 47f95cb294
Chore: Implement cSpell to detect spelling mistakes in codebase (#10001)
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
Co-authored-by: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com>
2024-02-26 10:16:23 +00:00

94 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);
});
// checkbox list
test('should NOT detect `+ [x]` as empty list item ', () => {
expect(markdownUtils.isEmptyListItem('+ [x]')).toBe(false);
});
});