Skip to content

Commit

Permalink
jest-haste-map: fix bug where platform-specific files are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Lauliac committed Feb 12, 2018
1 parent 508f789 commit fc0971c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ describe('HasteMap', () => {
});
});

it('correctly handles platform-specific file deletions (broken)', async () => {
it('correctly handles platform-specific file deletions', async () => {
mockFs = Object.create(null);
mockFs['/fruits/strawberry.js'] = [
'/**',
Expand All @@ -613,8 +613,6 @@ describe('HasteMap', () => {
({__hasteMapForTest: data} = await new HasteMap(defaultConfig).build());
expect(data.map['Strawberry']).toEqual({
g: ['/fruits/strawberry.js', 0],
// FIXME: this file should NOT exist anymore!
ios: ['/fruits/strawberry.ios.js', 0],
});
});

Expand Down
14 changes: 12 additions & 2 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,18 @@ class HasteMap extends EventEmitter {
if (fileMetadata[H.VISITED]) {
if (!fileMetadata[H.ID]) {
return null;
} else if (fileMetadata[H.ID] && moduleMetadata) {
map[fileMetadata[H.ID]] = moduleMetadata;
}
if (moduleMetadata != null) {
const platform =
getPlatformExtension(filePath, this._options.platforms) ||
H.GENERIC_PLATFORM;
const module = moduleMetadata[platform];
if (module == null) {
return null;
}
const modulesByPlatform = map[fileMetadata[H.ID]] ||
(map[fileMetadata[H.ID]] = {});
modulesByPlatform[platform] = module;
return null;
}
}
Expand Down

0 comments on commit fc0971c

Please sign in to comment.