Skip to content

Commit 55c342a

Browse files
jeanlauliaccpojer
authored andcommitted
jest-haste-map: fix bug where platform-specific files are removed (#5534)
* jest-haste-map: fix bug where platform-specific files are removed * add to changelog
1 parent 508f789 commit 55c342a

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## master
22

3+
### Fixes
4+
5+
* `[jest-haste-map]` Properly handle platform-specific file deletions
6+
([#5534](https://github.com/facebook/jest/pull/5534))
7+
38
### Features
49

510
* `[jest-util]` Add the following methods to the "console" implementations:

packages/jest-haste-map/src/__tests__/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ describe('HasteMap', () => {
586586
});
587587
});
588588

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

packages/jest-haste-map/src/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,18 @@ class HasteMap extends EventEmitter {
422422
if (fileMetadata[H.VISITED]) {
423423
if (!fileMetadata[H.ID]) {
424424
return null;
425-
} else if (fileMetadata[H.ID] && moduleMetadata) {
426-
map[fileMetadata[H.ID]] = moduleMetadata;
425+
}
426+
if (moduleMetadata != null) {
427+
const platform =
428+
getPlatformExtension(filePath, this._options.platforms) ||
429+
H.GENERIC_PLATFORM;
430+
const module = moduleMetadata[platform];
431+
if (module == null) {
432+
return null;
433+
}
434+
const modulesByPlatform =
435+
map[fileMetadata[H.ID]] || (map[fileMetadata[H.ID]] = {});
436+
modulesByPlatform[platform] = module;
427437
return null;
428438
}
429439
}

website/pages/en/videos.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class Videos extends React.Component {
3636
({title, description, type, url}, index) => {
3737
const textMarkup = (
3838
<div className="blockContent">
39-
<h2><a href={url}>{title}</a></h2>
39+
<h2>
40+
<a href={url}>{title}</a>
41+
</h2>
4042
<div>
4143
<MarkdownBlock>{description}</MarkdownBlock>
4244
</div>

0 commit comments

Comments
 (0)