From 6fd88ef12381786c72c6d23da1b0461a79814e17 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:19:28 +0000 Subject: [PATCH] Add unit tests for JWT module registration Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/jwt.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/stdlib/src/jwt.rs b/stdlib/src/jwt.rs index 6a1763d4..eb7db4dc 100644 --- a/stdlib/src/jwt.rs +++ b/stdlib/src/jwt.rs @@ -41,3 +41,40 @@ impl StdlibRegistry { ); } } + +#[cfg(test)] +mod tests { + use super::*; + use techscript_runtime::context::{RuntimeConfig, RuntimeContext}; + + #[test] + fn test_register_jwt() { + let mut registry = StdlibRegistry::new(); + registry.register_jwt(); + + let module = registry.get_module("std.jwt").unwrap(); + + let encode_fn = module.exports.get("encode").unwrap(); + assert_eq!(encode_fn.name(), "encode"); + assert_eq!(encode_fn.arity(), 2); + + let decode_fn = module.exports.get("decode").unwrap(); + assert_eq!(decode_fn.name(), "decode"); + assert_eq!(decode_fn.arity(), 2); + + let mut ctx = RuntimeContext::new(RuntimeConfig::default()); + + let encode_result = encode_fn + .call(&mut ctx, vec![RuntimeValue::Null, RuntimeValue::Null]) + .unwrap(); + assert_eq!( + encode_result, + RuntimeValue::Str("JWT encode not yet available".to_string()) + ); + + let decode_result = decode_fn + .call(&mut ctx, vec![RuntimeValue::Null, RuntimeValue::Null]) + .unwrap(); + assert_eq!(decode_result, RuntimeValue::Null); + } +}