Skip to content

Commit

Permalink
jest-haste-map: fix bug where platform-specific files are removed (#5534
Browse files Browse the repository at this point in the history
)

* jest-haste-map: fix bug where platform-specific files are removed

* add to changelog
  • Loading branch information
jeanlauliac authored and cpojer committed Feb 12, 2018
1 parent 508f789 commit 55c342a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## master

### Fixes

* `[jest-haste-map]` Properly handle platform-specific file deletions
([#5534](https://github.com/facebook/jest/pull/5534))

### Features

* `[jest-util]` Add the following methods to the "console" implementations:
Expand Down
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
4 changes: 3 additions & 1 deletion website/pages/en/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Videos extends React.Component {
({title, description, type, url}, index) => {
const textMarkup = (
<div className="blockContent">
<h2><a href={url}>{title}</a></h2>
<h2>
<a href={url}>{title}</a>
</h2>
<div>
<MarkdownBlock>{description}</MarkdownBlock>
</div>
Expand Down

0 comments on commit 55c342a

Please sign in to comment.