2020-09-10 14:34:08 +03:00
|
|
|
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
2021-01-14 12:17:44 +03:00
|
|
|
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
|
2020-09-10 14:34:08 +03:00
|
|
|
|
2021-01-29 16:37:48 +07:00
|
|
|
$os = Get-OSVersion
|
|
|
|
|
|
2020-12-23 22:14:13 +07:00
|
|
|
Describe "Node.js" {
|
|
|
|
|
It "Node.js is installed" {
|
2020-09-10 14:34:08 +03:00
|
|
|
"node --version" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 17:49:30 +03:00
|
|
|
It "Node.js version should correspond to the version in the toolset" {
|
|
|
|
|
node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*"
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 14:34:08 +03:00
|
|
|
It "NPM is installed" {
|
|
|
|
|
"npm --version" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Yarn is installed" {
|
|
|
|
|
"yarn --version" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 22:14:13 +07:00
|
|
|
Describe "nvm" {
|
2020-09-10 14:34:08 +03:00
|
|
|
BeforeAll {
|
|
|
|
|
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
|
|
|
|
|
$nvmInitCommand = ". $nvmPath > /dev/null 2>&1 || true"
|
|
|
|
|
}
|
2020-11-05 10:38:20 +03:00
|
|
|
|
2020-12-23 22:14:13 +07:00
|
|
|
It "nvm is installed" {
|
2020-09-10 14:34:08 +03:00
|
|
|
$nvmPath | Should -Exist
|
|
|
|
|
"$nvmInitCommand && nvm --version" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 22:14:13 +07:00
|
|
|
Context "nvm versions" {
|
2021-11-12 21:43:33 +03:00
|
|
|
[array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions'
|
|
|
|
|
$testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} }
|
2020-09-10 14:34:08 +03:00
|
|
|
|
|
|
|
|
It "<NvmVersion>" -TestCases $testCases {
|
|
|
|
|
param (
|
|
|
|
|
[string] $NvmVersion
|
|
|
|
|
)
|
2020-11-05 10:38:20 +03:00
|
|
|
|
2020-09-10 14:34:08 +03:00
|
|
|
"$nvmInitCommand && nvm ls $($NvmVersion)" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-29 16:37:48 +07:00
|
|
|
|
2021-09-09 18:53:11 +03:00
|
|
|
Describe "Global NPM Packages" {
|
|
|
|
|
$globalNpmPackages = Get-ToolsetValue "npm.global_packages"
|
|
|
|
|
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
|
|
|
|
|
|
|
|
|
|
It "<Name>" -TestCases $globalNpmPackagesWithTests {
|
|
|
|
|
$Test | Should -ReturnZeroExitCode
|
2021-01-29 16:37:48 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|