diff --git a/app-shell/src/protocol-storage/__tests__/file-system.test.ts b/app-shell/src/protocol-storage/__tests__/file-system.test.ts index 4da2cd23abe..cc742e0b89b 100644 --- a/app-shell/src/protocol-storage/__tests__/file-system.test.ts +++ b/app-shell/src/protocol-storage/__tests__/file-system.test.ts @@ -109,66 +109,67 @@ describe('protocol storage directory utilities', () => { }) describe('parseProtocolDirs', () => { - it('reads and parses directories', () => { + it('reads and parses directories', async () => { const protocolsDir = makeEmptyDir() - const firstProtocolDirName = 'protocol_item_1' const secondProtocolDirName = 'protocol_item_2' - const firstDirPath = path.join(protocolsDir, firstProtocolDirName) const secondDirPath = path.join(protocolsDir, secondProtocolDirName) - return Promise.all([ - fs.emptyDir(path.join(protocolsDir, firstProtocolDirName)), - fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src')), - fs.createFile( - path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py') - ), - fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'analysis')), - fs.createFile( - path.join( - protocolsDir, - firstProtocolDirName, - 'analysis', - 'fake_timestamp0.json' - ) - ), - fs.emptyDir(path.join(protocolsDir, secondProtocolDirName)), - fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src')), - fs.createFile( - path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json') - ), - fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'analysis')), - fs.createFile( - path.join( - protocolsDir, - secondProtocolDirName, - 'analysis', - 'fake_timestamp1.json' - ) - ), - ]).then(() => { - return expect( - parseProtocolDirs([firstDirPath, secondDirPath]) - ).resolves.toEqual([ - { - dirPath: firstDirPath, - modified: expect.any(Number), - srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')], - analysisFilePaths: [ - path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'), - ], - }, - { - dirPath: secondDirPath, - modified: expect.any(Number), - srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')], - analysisFilePaths: [ - path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'), - ], - }, - ]) - }) + await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName)) + await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src')) + await fs.emptyDir( + path.join(protocolsDir, firstProtocolDirName, 'analysis') + ) + await fs.createFile( + path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py') + ) + await fs.createFile( + path.join( + protocolsDir, + firstProtocolDirName, + 'analysis', + 'fake_timestamp0.json' + ) + ) + + await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName)) + await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src')) + await fs.emptyDir( + path.join(protocolsDir, secondProtocolDirName, 'analysis') + ) + await fs.createFile( + path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json') + ) + await fs.createFile( + path.join( + protocolsDir, + secondProtocolDirName, + 'analysis', + 'fake_timestamp1.json' + ) + ) + + const result = await parseProtocolDirs([firstDirPath, secondDirPath]) + + expect(result).toEqual([ + { + dirPath: firstDirPath, + modified: expect.any(Number), + srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')], + analysisFilePaths: [ + path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'), + ], + }, + { + dirPath: secondDirPath, + modified: expect.any(Number), + srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')], + analysisFilePaths: [ + path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'), + ], + }, + ]) }) })