|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const path = require('path'); |
| 4 | +const { loadMarkdownFile } = require('../helpers/file-loader'); |
| 5 | +const { |
| 6 | + REGEXP_HEADER, |
| 7 | + REGEXP_IMAGE, |
| 8 | + REGEXP_LINK, |
| 9 | + REGEXP_STRONG, |
| 10 | + REGEXP_DEL, |
| 11 | + REGEXP_Q, |
| 12 | + REGEXP_CODE, |
| 13 | + REGEXP_UL_LIST, |
| 14 | + REGEXP_OL_LIST, |
| 15 | + REGEXP_BLOCKQUOTE, |
| 16 | + REGEXP_HR, |
| 17 | + REGEXP_PARAGRAPH, |
| 18 | + REGEXP_EMPTY_UL, |
| 19 | + REGEXP_EMPTY_OL, |
| 20 | + REGEXP_BR, |
| 21 | + REGEXP_EMPTY_BLOCKQUOTE, |
| 22 | + REGEXP_EM, |
| 23 | +} = require('../../src/index'); |
| 24 | + |
| 25 | +const contentPath = path.resolve(__dirname, '../../source-fullcodetest.md'); |
| 26 | +const content = loadMarkdownFile(contentPath); |
| 27 | + |
| 28 | +describe('Integration: regex patterns against source-fullcodetest.md', () => { |
| 29 | + |
| 30 | + test('REGEXP_HEADER matches headers in the content', () => { |
| 31 | + const matches = content.match(REGEXP_HEADER); |
| 32 | + expect(matches).not.toBeNull(); |
| 33 | + expect(matches.length).toBeGreaterThan(0); |
| 34 | + }); |
| 35 | + |
| 36 | + test('REGEXP_IMAGE matches images in the content', () => { |
| 37 | + const matches = content.match(REGEXP_IMAGE); |
| 38 | + expect(matches).not.toBeNull(); |
| 39 | + expect(matches.length).toBeGreaterThan(0); |
| 40 | + }); |
| 41 | + |
| 42 | + test('REGEXP_LINK matches links in the content', () => { |
| 43 | + const matches = content.match(REGEXP_LINK); |
| 44 | + expect(matches).not.toBeNull(); |
| 45 | + expect(matches.length).toBeGreaterThan(0); |
| 46 | + }); |
| 47 | + |
| 48 | + test('REGEXP_OL_LIST matches ordered list items in the content', () => { |
| 49 | + const matches = content.match(REGEXP_OL_LIST); |
| 50 | + expect(matches).not.toBeNull(); |
| 51 | + expect(matches.length).toBeGreaterThan(0); |
| 52 | + }); |
| 53 | + |
| 54 | + test('REGEXP_BR matches line breaks in the content', () => { |
| 55 | + const matches = content.match(REGEXP_BR); |
| 56 | + expect(matches).not.toBeNull(); |
| 57 | + expect(matches.length).toBeGreaterThan(0); |
| 58 | + }); |
| 59 | + |
| 60 | + test('REGEXP_EM matches emphasis in the content', () => { |
| 61 | + const matches = content.match(REGEXP_EM); |
| 62 | + expect(matches).not.toBeNull(); |
| 63 | + expect(matches.length).toBeGreaterThan(0); |
| 64 | + }); |
| 65 | + |
| 66 | + test('REGEXP_PARAGRAPH matches paragraphs in the content', () => { |
| 67 | + const matches = content.match(REGEXP_PARAGRAPH); |
| 68 | + expect(matches).not.toBeNull(); |
| 69 | + expect(matches.length).toBeGreaterThan(0); |
| 70 | + }); |
| 71 | + |
| 72 | + test('REGEXP_STRONG matches bold-like patterns in the content', () => { |
| 73 | + const matches = content.match(REGEXP_STRONG); |
| 74 | + // source-fullcodetest.md contains "** 3. Automation technology...**" which is wrapped with ** |
| 75 | + expect(matches).not.toBeNull(); |
| 76 | + expect(matches.length).toBeGreaterThan(0); |
| 77 | + }); |
| 78 | + |
| 79 | + test('REGEXP_DEL does not produce false positives on this content', () => { |
| 80 | + const matches = content.match(REGEXP_DEL); |
| 81 | + // source-fullcodetest.md does not contain ~~strikethrough~~ text |
| 82 | + expect(matches).toBeNull(); |
| 83 | + }); |
| 84 | + |
| 85 | + test('REGEXP_Q does not produce false positives on this content', () => { |
| 86 | + const matches = content.match(REGEXP_Q); |
| 87 | + // source-fullcodetest.md does not contain :"quoted": text |
| 88 | + expect(matches).toBeNull(); |
| 89 | + }); |
| 90 | + |
| 91 | + test('REGEXP_CODE does not produce false positives on this content', () => { |
| 92 | + const matches = content.match(REGEXP_CODE); |
| 93 | + // source-fullcodetest.md does not contain `inline code` spans |
| 94 | + expect(matches).toBeNull(); |
| 95 | + }); |
| 96 | + |
| 97 | + test('REGEXP_UL_LIST matches list-like patterns in the content', () => { |
| 98 | + const matches = content.match(REGEXP_UL_LIST); |
| 99 | + // source-fullcodetest.md contains lines starting with * (e.g. "** 3. Automation..." and "***") |
| 100 | + expect(matches).not.toBeNull(); |
| 101 | + expect(matches.length).toBeGreaterThan(0); |
| 102 | + }); |
| 103 | + |
| 104 | + test('REGEXP_BLOCKQUOTE does not produce false positives on this content', () => { |
| 105 | + const matches = content.match(REGEXP_BLOCKQUOTE); |
| 106 | + // source-fullcodetest.md does not contain > blockquote lines |
| 107 | + expect(matches).toBeNull(); |
| 108 | + }); |
| 109 | + |
| 110 | + test('REGEXP_HR does not produce false positives on this content', () => { |
| 111 | + const matches = content.match(REGEXP_HR); |
| 112 | + // source-fullcodetest.md uses *** for dividers, not ----- (5+ dashes) |
| 113 | + expect(matches).toBeNull(); |
| 114 | + }); |
| 115 | + |
| 116 | + test('REGEXP_EMPTY_UL does not produce false positives on this content', () => { |
| 117 | + const matches = content.match(REGEXP_EMPTY_UL); |
| 118 | + // source-fullcodetest.md does not contain HTML list tags |
| 119 | + expect(matches).toBeNull(); |
| 120 | + }); |
| 121 | + |
| 122 | + test('REGEXP_EMPTY_OL does not produce false positives on this content', () => { |
| 123 | + const matches = content.match(REGEXP_EMPTY_OL); |
| 124 | + // source-fullcodetest.md does not contain HTML list tags |
| 125 | + expect(matches).toBeNull(); |
| 126 | + }); |
| 127 | + |
| 128 | + test('REGEXP_EMPTY_BLOCKQUOTE does not produce false positives on this content', () => { |
| 129 | + const matches = content.match(REGEXP_EMPTY_BLOCKQUOTE); |
| 130 | + // source-fullcodetest.md does not contain HTML blockquote tags |
| 131 | + expect(matches).toBeNull(); |
| 132 | + }); |
| 133 | + |
| 134 | +}); |
0 commit comments