diff options
author | Matan Kushner <hello@matchai.dev> | 2020-01-26 17:37:18 -0500 |
---|---|---|
committer | Kevin Song <chipbuster@users.noreply.github.com> | 2020-01-26 16:37:18 -0600 |
commit | 3365beae09af2f12b6323a52f88633ed97b39c51 (patch) | |
tree | fb36ec6c06439edd29775fc4a7b1a06041619b69 /src/modules/character.rs | |
parent | 5342dcc658110f8884a77ef1b3f83e867322ffb5 (diff) |
test(nodejs): Port nodejs module tests from E2E to integraton (#867)
Replaces the existing nodejs module end-to-end tests with integration tests that don't require preinstalled environmental dependencies.
- Moved the tests to the same file as the module they test
- Created a render_module utility function for rendering modules within tests
- Removed Node.js installation during CI setup
- Add Shell to Context to allow for tests to not run shell-specific code
Diffstat (limited to 'src/modules/character.rs')
-rw-r--r-- | src/modules/character.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/modules/character.rs b/src/modules/character.rs index cc9545172..e0c0ffe9e 100644 --- a/src/modules/character.rs +++ b/src/modules/character.rs @@ -1,5 +1,4 @@ -use super::{Context, Module, RootModuleConfig}; - +use super::{Context, Module, RootModuleConfig, Shell}; use crate::configs::character::CharacterConfig; /// Creates a module for the prompt character @@ -25,7 +24,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let props = &context.properties; let exit_code_default = std::string::String::from("0"); let exit_code = props.get("status_code").unwrap_or(&exit_code_default); - let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default(); let keymap_default = std::string::String::from("viins"); let keymap = props.get("keymap").unwrap_or(&keymap_default); let exit_success = exit_code == "0"; @@ -35,8 +33,8 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { // Unfortunately, this is also the name of the non-vi default mode. // We do some environment detection in src/init.rs to translate. // The result: in non-vi fish, keymap is always reported as "insert" - let mode = match (shell.as_str(), keymap.as_str()) { - ("fish", "default") | ("zsh", "vicmd") => ShellEditMode::Normal, + let mode = match (&context.shell, keymap.as_str()) { + (Shell::Fish, "default") | (Shell::Zsh, "vicmd") => ShellEditMode::Normal, _ => ASSUMED_MODE, }; |