Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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