From 3365beae09af2f12b6323a52f88633ed97b39c51 Mon Sep 17 00:00:00 2001 From: Matan Kushner Date: Sun, 26 Jan 2020 17:37:18 -0500 Subject: 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 --- src/modules/utils/mod.rs | 3 +++ src/modules/utils/test.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/modules/utils/test.rs (limited to 'src/modules/utils') diff --git a/src/modules/utils/mod.rs b/src/modules/utils/mod.rs index 6838fb19e..345ce7f40 100644 --- a/src/modules/utils/mod.rs +++ b/src/modules/utils/mod.rs @@ -1,2 +1,5 @@ pub mod directory; pub mod java_version_parser; + +#[cfg(test)] +pub mod test; diff --git a/src/modules/utils/test.rs b/src/modules/utils/test.rs new file mode 100644 index 000000000..b3c106b30 --- /dev/null +++ b/src/modules/utils/test.rs @@ -0,0 +1,12 @@ +use crate::config::StarshipConfig; +use crate::context::{Context, Shell}; +use std::path::Path; + +/// Render a specific starship module by name +pub fn render_module(module_name: &str, path: &Path) -> Option { + let mut context = Context::new_with_dir(clap::ArgMatches::default(), path); + context.config = StarshipConfig { config: None }; + context.shell = Shell::Unknown; + + crate::print::get_module(module_name, context) +} -- cgit v1.2.3