mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-18 17:41:11 +00:00
add unit tests
This commit is contained in:
parent
983e751c52
commit
fdd541042b
2 changed files with 48 additions and 6 deletions
|
@ -909,4 +909,44 @@ describe('setup-node', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('latest alias syntax', () => {
|
||||
it.each(['latest', 'current', 'node'])('download the %s version if alias is provided', async (inputVersion) => {
|
||||
// Arrange
|
||||
inputs['node-version'] = inputVersion;
|
||||
|
||||
os.platform = 'darwin';
|
||||
os.arch = 'x64';
|
||||
|
||||
const expectedVersion = nodeTestDist[0];
|
||||
|
||||
let expectedUrl = `https://nodejs.org/dist/${expectedVersion.version}/node-${expectedVersion.version}-${os.platform}-${os.arch}.tar.gz`;
|
||||
|
||||
findSpy.mockImplementation(() => '');
|
||||
getManifestSpy.mockImplementation(() => {
|
||||
throw new Error('Unable to download manifest');
|
||||
});
|
||||
|
||||
// Act
|
||||
await main.run();
|
||||
|
||||
// Assert
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
`Attempting to download ${inputVersion}...`
|
||||
);
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
'Unable to download manifest'
|
||||
);
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
'getting latest node version...'
|
||||
);
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
`Acquiring ${expectedVersion.version.substring(1, expectedVersion.version.length)} - ${os.arch} from ${expectedUrl}`
|
||||
);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue