From 5caa240d9577e3acd657d65200f24875ba38af86 Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Tue, 21 Mar 2023 07:43:05 -0700 Subject: [PATCH] Add integration test for changed file in new directory (#950) Summary: Cherry pick the new integration test covering https://github.com/facebook/react-native/issues/36387 from https://github.com/facebook/metro/pull/949 Pull Request resolved: https://github.com/facebook/metro/pull/950 Reviewed By: huntie Differential Revision: D44254000 Pulled By: robhogan fbshipit-source-id: 10d202ec153b55e8ecbe282d0b907fabee0fe5b6 --- .../watchers/__tests__/integration-test.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/metro-file-map/src/watchers/__tests__/integration-test.js b/packages/metro-file-map/src/watchers/__tests__/integration-test.js index 20d1c2443e..e95bc941fc 100644 --- a/packages/metro-file-map/src/watchers/__tests__/integration-test.js +++ b/packages/metro-file-map/src/watchers/__tests__/integration-test.js @@ -206,6 +206,33 @@ describe.each(Object.keys(WATCHERS))( }); }); + maybeTest('detects changes to files in a new directory', async () => { + expect( + await eventHelpers.nextEvent(() => mkdir(join(watchRoot, 'newdir'))), + ).toStrictEqual({ + path: join('newdir'), + eventType: 'add', + metadata: { + modifiedTime: expect.any(Number), + size: expect.any(Number), + type: 'd', + }, + }); + expect( + await eventHelpers.nextEvent(() => + writeFile(join(watchRoot, 'newdir', 'file-in-new-dir.js'), 'code'), + ), + ).toStrictEqual({ + path: join('newdir', 'file-in-new-dir.js'), + eventType: 'add', + metadata: { + modifiedTime: expect.any(Number), + size: expect.any(Number), + type: 'f', + }, + }); + }); + maybeTest( 'emits deletion for all files when a directory is deleted', async () => {