Skip to content

Commit 217420b

Browse files
authored
Merge pull request #80 from Tcode-Motion/jules-13250582641171105321-d4071c0f
🧪 [testing improvement] Add missing test for module registration in jwt.rs
2 parents 0b53bde + 6fd88ef commit 217420b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎stdlib/src/jwt.rs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,40 @@ impl StdlibRegistry {
4141
);
4242
}
4343
}
44+
45+
#[cfg(test)]
46+
mod tests {
47+
use super::*;
48+
use techscript_runtime::context::{RuntimeConfig, RuntimeContext};
49+
50+
#[test]
51+
fn test_register_jwt() {
52+
let mut registry = StdlibRegistry::new();
53+
registry.register_jwt();
54+
55+
let module = registry.get_module("std.jwt").unwrap();
56+
57+
let encode_fn = module.exports.get("encode").unwrap();
58+
assert_eq!(encode_fn.name(), "encode");
59+
assert_eq!(encode_fn.arity(), 2);
60+
61+
let decode_fn = module.exports.get("decode").unwrap();
62+
assert_eq!(decode_fn.name(), "decode");
63+
assert_eq!(decode_fn.arity(), 2);
64+
65+
let mut ctx = RuntimeContext::new(RuntimeConfig::default());
66+
67+
let encode_result = encode_fn
68+
.call(&mut ctx, vec![RuntimeValue::Null, RuntimeValue::Null])
69+
.unwrap();
70+
assert_eq!(
71+
encode_result,
72+
RuntimeValue::Str("JWT encode not yet available".to_string())
73+
);
74+
75+
let decode_result = decode_fn
76+
.call(&mut ctx, vec![RuntimeValue::Null, RuntimeValue::Null])
77+
.unwrap();
78+
assert_eq!(decode_result, RuntimeValue::Null);
79+
}
80+
}

0 commit comments

Comments
 (0)