[react-packager] Correct module extension regexp

This commit is contained in:
Amjad Masad 2015-04-09 12:17:32 -07:00
parent 21f1497418
commit 4b9ec6c5f7
2 changed files with 37 additions and 1 deletions

View File

@ -64,6 +64,42 @@ describe('DependencyGraph', function() {
});
});
pit('should get dependencies with the correct extensions', function() {
var root = '/root';
fs.__setMockFilesystem({
'root': {
'index.js': [
'/**',
' * @providesModule index',
' */',
'require("a")'
].join('\n'),
'a.js': [
'/**',
' * @providesModule a',
' */',
].join('\n'),
'a.js.orig': [
'/**',
' * @providesModule a',
' */',
].join('\n'),
}
});
var dgraph = new DependencyGraph({
roots: [root],
fileWatcher: fileWatcher
});
return dgraph.load().then(function() {
expect(dgraph.getOrderedDependencies('/root/index.js'))
.toEqual([
{id: 'index', altId: '/root/index.js', path: '/root/index.js', dependencies: ['a']},
{id: 'a', altId: '/root/a.js', path: '/root/a.js', dependencies: []},
]);
});
});
pit('should get dependencies with deprecated assets', function() {
var root = '/root';
fs.__setMockFilesystem({

View File

@ -65,7 +65,7 @@ function DependecyGraph(options) {
this._debugUpdateEvents = [];
this._moduleExtPattern = new RegExp(
'.' + ['js'].concat(this._assetExts).join('|') + '$'
'\.(' + ['js'].concat(this._assetExts).join('|') + ')$'
);
// Kick off the search process to precompute the dependency graph.