mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-08 13:11:11 +00:00
fix error in unit test
This commit is contained in:
parent
e3139593d9
commit
8dfead4556
4 changed files with 1426 additions and 214 deletions
|
@ -574,11 +574,25 @@ describe('setup-node', () => {
|
|||
expect(readFileSyncSpy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('warns if node-version and node-version-file are provided', async () => {
|
||||
//Arrange
|
||||
inputs['node-version'] = '12';
|
||||
inputs['node-version-file'] = '__tests__/data/.nvmrc';
|
||||
// Act
|
||||
await main.run();
|
||||
|
||||
// Assert
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
`Both node-version and node-version-file inputs are specified, only node-version will be used`
|
||||
);
|
||||
});
|
||||
|
||||
it('reads node-version-file if provided', async () => {
|
||||
// Arrange
|
||||
const versionSpec = 'v12';
|
||||
const versionFile = '.nvmrc';
|
||||
const expectedVersionSpec = '12';
|
||||
const versionSpec = 'v14';
|
||||
const versionFile = '__tests__/data/.nvmrc';
|
||||
const expectedVersionSpec = '14';
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, '..');
|
||||
inputs['node-version-file'] = versionFile;
|
||||
|
||||
|
@ -599,6 +613,25 @@ describe('setup-node', () => {
|
|||
`Resolved ${versionFile} as ${expectedVersionSpec}`
|
||||
);
|
||||
});
|
||||
|
||||
it('throws error if node-version-file doesnt exist', async () => {
|
||||
// Arrange
|
||||
const versionFile = '__tests__/meta/.nvmrc';
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, '..');
|
||||
inputs['node-version-file'] = versionFile;
|
||||
|
||||
// Act
|
||||
await main.run();
|
||||
|
||||
// Assert
|
||||
expect(existsSpy).toHaveBeenCalledTimes(1);
|
||||
expect(existsSpy).toHaveBeenCalledWith(
|
||||
path.join(process.env.GITHUB_WORKSPACE, versionFile)
|
||||
);
|
||||
expect(cnSpy).toHaveBeenCalledWith(
|
||||
`::error::The specified node version file does not exist${osm.EOL}`
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('LTS version', () => {
|
||||
beforeEach(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue