Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/src/platform/wasm/mobile_detection/user_agent_tests.rs
1use super::*;
2 
3#[test]
4fn test_ios() {
5 let ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15";
6 assert!(is_mobile_user_agent(ua));
7}
8 
9#[test]
10fn test_android() {
11 let ua = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 Chrome/108.0.0.0 Mobile Safari/537.36";
12 assert!(is_mobile_user_agent(ua));
13}
14 
15#[test]
16fn test_desktop() {
17 assert!(!is_mobile_user_agent(
18 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
19 ));
20 assert!(!is_mobile_user_agent(
21 "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
22 ));
23}
24 
25#[test]
26fn test_empty_user_agent() {
27 assert!(!is_mobile_user_agent(""));
28}
29 
30#[test]
31fn test_case_insensitivity() {
32 let ua = "MOZILLA/5.0 (IPHONE; CPU IPHONE OS 16_0 LIKE MAC OS X)";
33 assert!(is_mobile_user_agent(ua));
34}
35