Skip to content

Commit 4103f94

Browse files
committed
feat(utils): MODULES_REGEX
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent a9b18c7 commit 4103f94

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file Unit Tests - MODULES_REGEX
3+
* @module estree-util-unassert/utils/tests/unit/MODULES_REGEX
4+
*/
5+
6+
import TEST_SUBJECT from '../modules-regex'
7+
8+
describe('unit:utils/MODULES_REGEX', () => {
9+
beforeEach(() => {
10+
TEST_SUBJECT.lastIndex = 0
11+
})
12+
13+
it('should match "assert"', () => {
14+
expect(TEST_SUBJECT.test('assert')).to.be.true
15+
})
16+
17+
it('should match "devlop"', () => {
18+
expect(TEST_SUBJECT.test('devlop')).to.be.true
19+
})
20+
21+
it('should match "node:assert"', () => {
22+
expect(TEST_SUBJECT.test('node:assert')).to.be.true
23+
})
24+
25+
it('should match "node:assert/strict"', () => {
26+
expect(TEST_SUBJECT.test('node:assert/strict')).to.be.true
27+
})
28+
29+
it('should match "power-assert"', () => {
30+
expect(TEST_SUBJECT.test('power-assert')).to.be.true
31+
})
32+
33+
it('should match "uvu/assert"', () => {
34+
expect(TEST_SUBJECT.test('uvu/assert')).to.be.true
35+
})
36+
})

src/utils/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @file Entry Point - Utilities
3+
* @module estree-util-unassert/utils
4+
*/
5+
6+
export { default as MODULES_REGEX } from './modules-regex'

src/utils/modules-regex.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @file Utilities - MODULES_REGEX
3+
* @module estree-util-unassert/utils/MODULES_REGEX
4+
*/
5+
6+
/**
7+
* Default regular expression used to match assertion module ids.
8+
*
9+
* @const {RegExp} MODULES_REGEX
10+
*/
11+
const MODULES_REGEX: RegExp =
12+
/^(?:(?:(?:power-)|(?:uvu\/))?assert|devlop|(?:node:)?assert(?:\/strict)?)$/
13+
14+
export default MODULES_REGEX

0 commit comments

Comments
 (0)