From 0653f8a2a45045a153e3d468705f70d4b94a48b0 Mon Sep 17 00:00:00 2001 From: Pedro Fialho Date: Mon, 26 Dec 2022 17:50:42 -0300 Subject: [PATCH] add e2e tests for `latest` --- e2e/__snapshots__/latest.test.ts.snap | 32 +++++++++++++++++++++++++++ e2e/latest.test.ts | 19 ++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 e2e/__snapshots__/latest.test.ts.snap create mode 100644 e2e/latest.test.ts diff --git a/e2e/__snapshots__/latest.test.ts.snap b/e2e/__snapshots__/latest.test.ts.snap new file mode 100644 index 0000000..8b25da3 --- /dev/null +++ b/e2e/__snapshots__/latest.test.ts.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Bash installs latest: Bash 1`] = ` +"set -e +eval "$(fnm env)" +fnm install --latest +(fnm ls) | grep latest || (echo "Expected output to contain latest" && exit 1) +fnm use 'latest'" +`; + +exports[`Fish installs latest: Fish 1`] = ` +"fnm env | source +fnm install --latest +begin; fnm ls; end | grep latest; or echo "Expected output to contain latest" && exit 1 +fnm use 'latest'" +`; + +exports[`PowerShell installs latest: PowerShell 1`] = ` +"$ErrorActionPreference = "Stop" +fnm env | Out-String | Invoke-Expression +fnm install --latest +$($__out__ = $(fnm ls | Select-String latest); if ($__out__ -eq $null) { exit 1 } else { $__out__ }) +fnm use 'latest'" +`; + +exports[`Zsh installs latest: Zsh 1`] = ` +"set -e +eval "$(fnm env)" +fnm install --latest +(fnm ls) | grep latest || (echo "Expected output to contain latest" && exit 1) +fnm use 'latest'" +`; diff --git a/e2e/latest.test.ts b/e2e/latest.test.ts new file mode 100644 index 0000000..8d2a0fd --- /dev/null +++ b/e2e/latest.test.ts @@ -0,0 +1,19 @@ +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" + +for (const shell of [Bash, Zsh, Fish, PowerShell]) { + describe(shell, () => { + test(`installs latest`, async () => { + await script(shell) + .then(shell.env({})) + .then(shell.call("fnm", ["install", "--latest"])) + .then( + shell.scriptOutputContains(shell.call("fnm", ["ls"]), "latest") + ) + .then(shell.call("fnm", ["use", "'latest'"])) + .takeSnapshot(shell) + .execute(shell) + }) + }) +}