faker_rust/default/
tea.rs1use crate::base::sample;
4use crate::locale::fetch_locale;
5
6pub fn r#type() -> String {
8 fetch_locale("tea.types", "en")
9 .map(|v| sample(&v))
10 .unwrap_or_else(|| sample(FALLBACK_TYPES).to_string())
11}
12
13pub fn variety() -> String {
15 fetch_locale("tea.varieties", "en")
16 .map(|v| sample(&v))
17 .unwrap_or_else(|| sample(FALLBACK_VARIETIES).to_string())
18}
19
20pub fn origin() -> String {
22 fetch_locale("tea.origins", "en")
23 .map(|v| sample(&v))
24 .unwrap_or_else(|| sample(FALLBACK_ORIGINS).to_string())
25}
26
27const FALLBACK_TYPES: &[&str] = &[
29 "Black", "Green", "White", "Oolong", "Pu-erh", "Herbal", "Rooibos",
30 "Mate", "Chai", "Matcha", "Sencha", "Earl Grey", "Darjeeling",
31];
32
33const FALLBACK_VARIETIES: &[&str] = &[
34 "English Breakfast", "Earl Grey", "Jasmine", "Chamomile", "Peppermint",
35 "Green Tea", "Oolong", "White Tea", "Masala Chai", "Matcha",
36 "Sencha", "Gyokuro", "Dragon Well", "Tie Guan Yin", "Da Hong Pao",
37];
38
39const FALLBACK_ORIGINS: &[&str] = &[
40 "China", "India", "Japan", "Sri Lanka", "Taiwan", "Kenya", "Indonesia",
41 "Vietnam", "Turkey", "Iran", "Argentina", "South Africa",
42];
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_type() {
50 assert!(!r#type().is_empty());
51 }
52
53 #[test]
54 fn test_variety() {
55 assert!(!variety().is_empty());
56 }
57
58 #[test]
59 fn test_origin() {
60 assert!(!origin().is_empty());
61 }
62}