-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update how and when we read lock file
- Loading branch information
Showing
15 changed files
with
154 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import path from 'path'; | |
import { YarnClassicLockFileReader } from './yarn_classic_lock_file_reader'; | ||
|
||
void describe('YarnClassicLockFileReader', () => { | ||
const fspAccessMock = mock.method(fsp, 'access', () => true); | ||
const fspReadFileMock = mock.method( | ||
fsp, | ||
'readFile', | ||
|
@@ -51,37 +50,18 @@ [email protected]: | |
}; | ||
assert.deepEqual(lockFileContents, expectedLockFileContents); | ||
assert.strictEqual( | ||
fspAccessMock.mock.calls[0].arguments[0], | ||
fspReadFileMock.mock.calls[0].arguments[0], | ||
path.resolve(process.cwd(), 'yarn.lock') | ||
); | ||
assert.strictEqual(fspReadFileMock.mock.callCount(), 1); | ||
}); | ||
|
||
void it('throws when yarn.lock is not present', async () => { | ||
fspAccessMock.mock.mockImplementationOnce(() => | ||
Promise.reject(new Error()) | ||
); | ||
await assert.rejects( | ||
() => yarnClassicLockFileReader.getLockFileContentsFromCwd(), | ||
(error: Error) => { | ||
assert.ok(error.message.startsWith('Could not find a yarn.lock file')); | ||
return true; | ||
} | ||
); | ||
assert.strictEqual(fspReadFileMock.mock.callCount(), 0); | ||
}); | ||
|
||
void it('throws when yarn.lock is not parse-able', async () => { | ||
void it('returns empty lock file contents when yarn.lock is not present or parse-able', async () => { | ||
fspReadFileMock.mock.mockImplementationOnce(() => | ||
Promise.reject(new Error()) | ||
); | ||
await assert.rejects( | ||
() => yarnClassicLockFileReader.getLockFileContentsFromCwd(), | ||
(error: Error) => { | ||
assert.ok(error.message.startsWith('Could not parse the contents')); | ||
return true; | ||
} | ||
); | ||
assert.strictEqual(fspReadFileMock.mock.callCount(), 1); | ||
const lockFileContents = | ||
await yarnClassicLockFileReader.getLockFileContentsFromCwd(); | ||
assert.deepEqual(lockFileContents, { dependencies: [] }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.