Skip to content

Commit

Permalink
feat(utils): MODULES_REGEX
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Feb 28, 2024
1 parent a9b18c7 commit 4103f94
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/utils/__tests__/modules-regex.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file Unit Tests - MODULES_REGEX
* @module estree-util-unassert/utils/tests/unit/MODULES_REGEX
*/

import TEST_SUBJECT from '../modules-regex'

describe('unit:utils/MODULES_REGEX', () => {
beforeEach(() => {
TEST_SUBJECT.lastIndex = 0
})

it('should match "assert"', () => {
expect(TEST_SUBJECT.test('assert')).to.be.true
})

it('should match "devlop"', () => {
expect(TEST_SUBJECT.test('devlop')).to.be.true
})

it('should match "node:assert"', () => {
expect(TEST_SUBJECT.test('node:assert')).to.be.true
})

it('should match "node:assert/strict"', () => {
expect(TEST_SUBJECT.test('node:assert/strict')).to.be.true
})

it('should match "power-assert"', () => {
expect(TEST_SUBJECT.test('power-assert')).to.be.true
})

it('should match "uvu/assert"', () => {
expect(TEST_SUBJECT.test('uvu/assert')).to.be.true
})
})
6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @file Entry Point - Utilities
* @module estree-util-unassert/utils
*/

export { default as MODULES_REGEX } from './modules-regex'
14 changes: 14 additions & 0 deletions src/utils/modules-regex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @file Utilities - MODULES_REGEX
* @module estree-util-unassert/utils/MODULES_REGEX
*/

/**
* Default regular expression used to match assertion module ids.
*
* @const {RegExp} MODULES_REGEX
*/
const MODULES_REGEX: RegExp =
/^(?:(?:(?:power-)|(?:uvu\/))?assert|devlop|(?:node:)?assert(?:\/strict)?)$/

export default MODULES_REGEX

0 comments on commit 4103f94

Please sign in to comment.