@@ -1364,13 +1364,13 @@ describe('HasteMap', () => {
1364
1364
}
1365
1365
1366
1366
hm_it ( 'build returns a "live" fileSystem and hasteModuleMap' , async hm => {
1367
- const initialResult = await hm . build ( ) ;
1367
+ const { fileSystem , hasteModuleMap } = await hm . build ( ) ;
1368
1368
const filePath = path . join ( '/' , 'project' , 'fruits' , 'Banana.js' ) ;
1369
- expect ( initialResult . fileSystem . getModuleName ( filePath ) ) . toBeDefined ( ) ;
1370
- expect ( initialResult . hasteModuleMap . getModule ( 'Banana' ) ) . toBe ( filePath ) ;
1369
+ expect ( fileSystem . getModuleName ( filePath ) ) . toBeDefined ( ) ;
1370
+ expect ( hasteModuleMap . getModule ( 'Banana' ) ) . toBe ( filePath ) ;
1371
1371
mockDeleteFile ( path . join ( '/' , 'project' , 'fruits' ) , 'Banana.js' ) ;
1372
1372
mockDeleteFile ( path . join ( '/' , 'project' , 'fruits' ) , 'Banana.js' ) ;
1373
- const { eventsQueue, snapshotFS , moduleMap } = await waitForItToChange ( hm ) ;
1373
+ const { eventsQueue} = await waitForItToChange ( hm ) ;
1374
1374
expect ( eventsQueue ) . toHaveLength ( 1 ) ;
1375
1375
const deletedBanana = {
1376
1376
filePath,
@@ -1379,10 +1379,8 @@ describe('HasteMap', () => {
1379
1379
} ;
1380
1380
expect ( eventsQueue ) . toEqual ( [ deletedBanana ] ) ;
1381
1381
// Verify that the initial result has been updated
1382
- expect ( initialResult . fileSystem . getModuleName ( filePath ) ) . toBeNull ( ) ;
1383
- expect ( initialResult . hasteModuleMap . getModule ( 'Banana' ) ) . toBeNull ( ) ;
1384
- expect ( snapshotFS . getModuleName ( filePath ) ) . toBeNull ( ) ;
1385
- expect ( moduleMap . getModule ( 'Banana' ) ) . toBeNull ( ) ;
1382
+ expect ( fileSystem . getModuleName ( filePath ) ) . toBeNull ( ) ;
1383
+ expect ( hasteModuleMap . getModule ( 'Banana' ) ) . toBeNull ( ) ;
1386
1384
} ) ;
1387
1385
1388
1386
const MOCK_CHANGE_FILE = {
@@ -1398,6 +1396,7 @@ describe('HasteMap', () => {
1398
1396
} ;
1399
1397
1400
1398
hm_it ( 'handles several change events at once' , async hm => {
1399
+ const { fileSystem, hasteModuleMap} = await hm . build ( ) ;
1401
1400
mockFs [ path . join ( '/' , 'project' , 'fruits' , 'Tomato.js' ) ] = `
1402
1401
// Tomato!
1403
1402
` ;
@@ -1419,7 +1418,7 @@ describe('HasteMap', () => {
1419
1418
path . join ( '/' , 'project' , 'fruits' ) ,
1420
1419
MOCK_CHANGE_FILE ,
1421
1420
) ;
1422
- const { eventsQueue, snapshotFS , moduleMap } = await waitForItToChange ( hm ) ;
1421
+ const { eventsQueue} = await waitForItToChange ( hm ) ;
1423
1422
expect ( eventsQueue ) . toEqual ( [
1424
1423
{
1425
1424
filePath : path . join ( '/' , 'project' , 'fruits' , 'Tomato.js' ) ,
@@ -1433,12 +1432,12 @@ describe('HasteMap', () => {
1433
1432
} ,
1434
1433
] ) ;
1435
1434
expect (
1436
- snapshotFS . getModuleName (
1435
+ fileSystem . getModuleName (
1437
1436
path . join ( '/' , 'project' , 'fruits' , 'Tomato.js' ) ,
1438
1437
) ,
1439
1438
) . not . toBeNull ( ) ;
1440
- expect ( moduleMap . getModule ( 'Tomato' ) ) . toBeDefined ( ) ;
1441
- expect ( moduleMap . getModule ( 'Pear' ) ) . toBe (
1439
+ expect ( hasteModuleMap . getModule ( 'Tomato' ) ) . toBeDefined ( ) ;
1440
+ expect ( hasteModuleMap . getModule ( 'Pear' ) ) . toBe (
1442
1441
path . join ( '/' , 'project' , 'fruits' , 'Pear.js' ) ,
1443
1442
) ;
1444
1443
} ) ;
@@ -1466,6 +1465,7 @@ describe('HasteMap', () => {
1466
1465
hm_it (
1467
1466
'emits a change even if a file in node_modules has changed' ,
1468
1467
async hm => {
1468
+ const { fileSystem} = await hm . build ( ) ;
1469
1469
const e = mockEmitters [ path . join ( '/' , 'project' , 'fruits' ) ] ;
1470
1470
e . emit (
1471
1471
'all' ,
@@ -1474,7 +1474,7 @@ describe('HasteMap', () => {
1474
1474
path . join ( '/' , 'project' , 'fruits' , 'node_modules' , '' ) ,
1475
1475
MOCK_CHANGE_FILE ,
1476
1476
) ;
1477
- const { eventsQueue, snapshotFS } = await waitForItToChange ( hm ) ;
1477
+ const { eventsQueue} = await waitForItToChange ( hm ) ;
1478
1478
const filePath = path . join (
1479
1479
'/' ,
1480
1480
'project' ,
@@ -1486,16 +1486,16 @@ describe('HasteMap', () => {
1486
1486
expect ( eventsQueue ) . toEqual ( [
1487
1487
{ filePath, metadata : MOCK_CHANGE_FILE , type : 'add' } ,
1488
1488
] ) ;
1489
- expect ( snapshotFS . getModuleName ( filePath ) ) . toBeDefined ( ) ;
1489
+ expect ( fileSystem . getModuleName ( filePath ) ) . toBeDefined ( ) ;
1490
1490
} ,
1491
1491
) ;
1492
1492
1493
1493
hm_it (
1494
1494
'correctly tracks changes to both platform-specific versions of a single module name' ,
1495
1495
async hm => {
1496
- const { hasteModuleMap : initMM } = await hm . build ( ) ;
1497
- expect ( initMM . getModule ( 'Orange' , 'ios' ) ) . toBeTruthy ( ) ;
1498
- expect ( initMM . getModule ( 'Orange' , 'android' ) ) . toBeTruthy ( ) ;
1496
+ const { hasteModuleMap, fileSystem } = await hm . build ( ) ;
1497
+ expect ( hasteModuleMap . getModule ( 'Orange' , 'ios' ) ) . toBeTruthy ( ) ;
1498
+ expect ( hasteModuleMap . getModule ( 'Orange' , 'android' ) ) . toBeTruthy ( ) ;
1499
1499
const e = mockEmitters [ path . join ( '/' , 'project' , 'fruits' ) ] ;
1500
1500
e . emit (
1501
1501
'all' ,
@@ -1511,9 +1511,7 @@ describe('HasteMap', () => {
1511
1511
path . join ( '/' , 'project' , 'fruits' ) ,
1512
1512
MOCK_CHANGE_FILE ,
1513
1513
) ;
1514
- const { eventsQueue, snapshotFS, moduleMap} = await waitForItToChange (
1515
- hm ,
1516
- ) ;
1514
+ const { eventsQueue} = await waitForItToChange ( hm ) ;
1517
1515
expect ( eventsQueue ) . toHaveLength ( 2 ) ;
1518
1516
expect ( eventsQueue ) . toEqual ( [
1519
1517
{
@@ -1528,20 +1526,20 @@ describe('HasteMap', () => {
1528
1526
} ,
1529
1527
] ) ;
1530
1528
expect (
1531
- snapshotFS . getModuleName (
1529
+ fileSystem . getModuleName (
1532
1530
path . join ( '/' , 'project' , 'fruits' , 'Orange.ios.js' ) ,
1533
1531
) ,
1534
1532
) . toBeTruthy ( ) ;
1535
1533
expect (
1536
- snapshotFS . getModuleName (
1534
+ fileSystem . getModuleName (
1537
1535
path . join ( '/' , 'project' , 'fruits' , 'Orange.android.js' ) ,
1538
1536
) ,
1539
1537
) . toBeTruthy ( ) ;
1540
- const iosVariant = moduleMap . getModule ( 'Orange' , 'ios' ) ;
1538
+ const iosVariant = hasteModuleMap . getModule ( 'Orange' , 'ios' ) ;
1541
1539
expect ( iosVariant ) . toBe (
1542
1540
path . join ( '/' , 'project' , 'fruits' , 'Orange.ios.js' ) ,
1543
1541
) ;
1544
- const androidVariant = moduleMap . getModule ( 'Orange' , 'android' ) ;
1542
+ const androidVariant = hasteModuleMap . getModule ( 'Orange' , 'android' ) ;
1545
1543
expect ( androidVariant ) . toBe (
1546
1544
path . join ( '/' , 'project' , 'fruits' , 'Orange.android.js' ) ,
1547
1545
) ;
@@ -1560,6 +1558,7 @@ describe('HasteMap', () => {
1560
1558
1561
1559
describe ( 'recovery from duplicate module IDs' , ( ) => {
1562
1560
async function setupDuplicates ( hm ) {
1561
+ const { fileSystem, hasteModuleMap} = await hm . build ( ) ;
1563
1562
mockFs [ path . join ( '/' , 'project' , 'fruits' , 'Pear.js' ) ] = `
1564
1563
// Pear!
1565
1564
` ;
@@ -1581,14 +1580,14 @@ describe('HasteMap', () => {
1581
1580
path . join ( '/' , 'project' , 'fruits' , 'another' ) ,
1582
1581
MOCK_CHANGE_FILE ,
1583
1582
) ;
1584
- const { snapshotFS , moduleMap } = await waitForItToChange ( hm ) ;
1583
+ await waitForItToChange ( hm ) ;
1585
1584
expect (
1586
- snapshotFS . exists (
1585
+ fileSystem . exists (
1587
1586
path . join ( '/' , 'project' , 'fruits' , 'another' , 'Pear.js' ) ,
1588
1587
) ,
1589
1588
) . toBe ( true ) ;
1590
1589
try {
1591
- moduleMap . getModule ( 'Pear' ) ;
1590
+ hasteModuleMap . getModule ( 'Pear' ) ;
1592
1591
throw new Error ( 'should be unreachable' ) ;
1593
1592
} catch ( error ) {
1594
1593
const {
@@ -1612,6 +1611,7 @@ describe('HasteMap', () => {
1612
1611
hm_it (
1613
1612
'recovers when the oldest version of the duplicates is fixed' ,
1614
1613
async hm => {
1614
+ const { hasteModuleMap} = await hm . build ( ) ;
1615
1615
await setupDuplicates ( hm ) ;
1616
1616
mockFs [ path . join ( '/' , 'project' , 'fruits' , 'Pear.js' ) ] = null ;
1617
1617
mockFs [ path . join ( '/' , 'project' , 'fruits' , 'Pear2.js' ) ] = `
@@ -1632,17 +1632,18 @@ describe('HasteMap', () => {
1632
1632
path . join ( '/' , 'project' , 'fruits' ) ,
1633
1633
MOCK_CHANGE_FILE ,
1634
1634
) ;
1635
- const { moduleMap } = await waitForItToChange ( hm ) ;
1636
- expect ( moduleMap . getModule ( 'Pear' ) ) . toBe (
1635
+ await waitForItToChange ( hm ) ;
1636
+ expect ( hasteModuleMap . getModule ( 'Pear' ) ) . toBe (
1637
1637
path . join ( '/' , 'project' , 'fruits' , 'another' , 'Pear.js' ) ,
1638
1638
) ;
1639
- expect ( moduleMap . getModule ( 'Pear2' ) ) . toBe (
1639
+ expect ( hasteModuleMap . getModule ( 'Pear2' ) ) . toBe (
1640
1640
path . join ( '/' , 'project' , 'fruits' , 'Pear2.js' ) ,
1641
1641
) ;
1642
1642
} ,
1643
1643
) ;
1644
1644
1645
1645
hm_it ( 'recovers when the most recent duplicate is fixed' , async hm => {
1646
+ const { hasteModuleMap} = await hm . build ( ) ;
1646
1647
await setupDuplicates ( hm ) ;
1647
1648
mockFs [ path . join ( '/' , 'project' , 'fruits' , 'another' , 'Pear.js' ) ] =
1648
1649
null ;
@@ -1664,11 +1665,11 @@ describe('HasteMap', () => {
1664
1665
path . join ( '/' , 'project' , 'fruits' , 'another' ) ,
1665
1666
MOCK_CHANGE_FILE ,
1666
1667
) ;
1667
- const { moduleMap } = await waitForItToChange ( hm ) ;
1668
- expect ( moduleMap . getModule ( 'Pear' ) ) . toBe (
1668
+ await waitForItToChange ( hm ) ;
1669
+ expect ( hasteModuleMap . getModule ( 'Pear' ) ) . toBe (
1669
1670
path . join ( '/' , 'project' , 'fruits' , 'Pear.js' ) ,
1670
1671
) ;
1671
- expect ( moduleMap . getModule ( 'Pear2' ) ) . toBe (
1672
+ expect ( hasteModuleMap . getModule ( 'Pear2' ) ) . toBe (
1672
1673
path . join ( '/' , 'project' , 'fruits' , 'another' , 'Pear2.js' ) ,
1673
1674
) ;
1674
1675
} ) ;
0 commit comments