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 c6055a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 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
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 c6055a9

Please sign in to comment.