Validating Module Specifier Processing in Parcel Bundler
This test suite validates the module specifier functionality in Parcel bundler, ensuring proper handling of package names and paths. It verifies both valid module specifications and invalid path handling.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
parcel-bundler/parcel
packages/core/package-manager/test/validateModuleSpecifiers.test.js
// @flow
import assert from 'assert';
import validateModuleSpecifier from '../src/validateModuleSpecifier';
describe('Validate Module Specifiers', () => {
it('Validate Module Specifiers', () => {
let modules = [
'@parcel/transformer-posthtml/package.json',
'@some-org/[email protected]',
'@org/[email protected]',
'something.js/something/index.js',
'@some.org/something.js/index.js',
'lodash/something/index.js',
];
assert.deepEqual(
modules.map(module => validateModuleSpecifier(module)),
[
'@parcel/transformer-posthtml',
'@some-org/[email protected]',
'@org/[email protected]',
'something.js',
'@some.org/something.js',
'lodash',
],
);
});
it('Return empty on invalid modules', () => {
let modules = ['./somewhere.js', './hello/world.js', '~/hello/world.js'];
assert.deepEqual(
modules.map(module => validateModuleSpecifier(module)),
['', '', ''],
);
});
});