Skip to content

Commit cd68566

Browse files
committed
Add unit tests for list regex patterns
1 parent 7d0ccf2 commit cd68566

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/list.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const assert = require('assert');
2+
const { REGEXP_UL_LIST, REGEXP_OL_LIST, REGEXP_EMPTY_UL, REGEXP_EMPTY_OL } = require('../src/index'); // Adjust the import according to your file structure
3+
4+
describe('Markdown Regex Patterns', function() {
5+
describe('UL List', function() {
6+
it('should match unordered lists correctly', function() {
7+
const matchValid = "* Item 1\n* Item 2";
8+
assert.ok(REGEXP_UL_LIST.test(matchValid));
9+
});
10+
11+
it('should not match invalid unordered lists', function() {
12+
const invalidMatch = "Item 1\nItem 2";
13+
assert.ok(!REGEXP_UL_LIST.test(invalidMatch));
14+
});
15+
16+
it('should match empty unordered lists', function() {
17+
const emptyList = "* "
18+
assert.ok(REGEXP_EMPTY_UL.test(emptyList));
19+
});
20+
});
21+
22+
describe('OL List', function() {
23+
it('should match ordered lists correctly', function() {
24+
const matchValid = "1. Item 1\n2. Item 2";
25+
assert.ok(REGEXP_OL_LIST.test(matchValid));
26+
});
27+
28+
it('should not match invalid ordered lists', function() {
29+
const invalidMatch = "Item 1\nItem 2";
30+
assert.ok(!REGEXP_OL_LIST.test(invalidMatch));
31+
});
32+
33+
it('should match empty ordered lists', function() {
34+
const emptyList = "1. "
35+
assert.ok(REGEXP_EMPTY_OL.test(emptyList));
36+
});
37+
});
38+
});

0 commit comments

Comments
 (0)