|
63 | 63 |
|
64 | 64 | #[test]
|
65 | 65 | fn test_comparison() {
|
66 |
| - let x = r#" |
| 66 | + let origin = r#" |
67 | 67 | @a {
|
68 | 68 | b {}
|
| 69 | + c {} |
69 | 70 | }
|
70 | 71 | "#;
|
71 | 72 |
|
72 |
| - let y = r#" |
| 73 | + let against = r#" |
73 | 74 | @a {
|
74 | 75 | b {}
|
75 |
| - c {} |
76 | 76 | }
|
77 | 77 | "#;
|
78 | 78 |
|
79 |
| - let against = load_css_paths(y).unwrap(); |
80 |
| - let other = load_css_paths(x).unwrap(); |
| 79 | + let origin = load_css_paths(origin).unwrap(); |
| 80 | + let against = load_css_paths(against).unwrap(); |
81 | 81 |
|
82 | 82 | let mut ret = Vec::new();
|
83 |
| - get_differences(&against, &other, &mut ret); |
| 83 | + get_differences(&against, &origin, &mut ret); |
84 | 84 | assert!(ret.is_empty());
|
85 |
| - get_differences(&other, &against, &mut ret); |
| 85 | + get_differences(&origin, &against, &mut ret); |
86 | 86 | assert_eq!(ret, vec![" Missing rule `c`".to_owned()]);
|
87 | 87 | }
|
88 | 88 |
|
@@ -123,13 +123,49 @@ fn test_media() {
|
123 | 123 | x: y;
|
124 | 124 | }
|
125 | 125 | }
|
| 126 | +
|
| 127 | +@media (max-width: 1001px) { |
| 128 | + b { |
| 129 | + x: y; |
| 130 | + } |
| 131 | +} |
126 | 132 | "#;
|
127 | 133 |
|
128 | 134 | let paths = load_css_paths(text).unwrap();
|
129 |
| - eprintln!("{:?}", paths); |
130 | 135 | let p = paths.get("@media (min-width:701px)");
|
131 | 136 | assert!(p.is_some());
|
132 | 137 | let p = p.unwrap();
|
133 | 138 | assert!(p.children.get("a:hover").is_some());
|
134 | 139 | assert!(p.children.get("b").is_some());
|
| 140 | + |
| 141 | + eprintln!("{:?}", paths); |
| 142 | + let p = paths.get("@media (max-width:1001px)"); |
| 143 | + assert!(p.is_some()); |
| 144 | + let p = p.unwrap(); |
| 145 | + assert!(p.children.get("b").is_some()); |
| 146 | +} |
| 147 | + |
| 148 | +#[test] |
| 149 | +fn test_css_variables() { |
| 150 | + let x = r#" |
| 151 | +:root { |
| 152 | + --a: #fff; |
| 153 | +} |
| 154 | +"#; |
| 155 | + |
| 156 | + let y = r#" |
| 157 | +:root { |
| 158 | + --a: #fff; |
| 159 | + --b: #fff; |
| 160 | +} |
| 161 | +"#; |
| 162 | + |
| 163 | + let against = load_css_paths(x).unwrap(); |
| 164 | + let other = load_css_paths(y).unwrap(); |
| 165 | + |
| 166 | + let mut ret = Vec::new(); |
| 167 | + get_differences(&against, &other, &mut ret); |
| 168 | + assert!(ret.is_empty()); |
| 169 | + get_differences(&other, &against, &mut ret); |
| 170 | + assert_eq!(ret, vec![" Missing CSS variable `--b` in `:root`".to_owned()]); |
135 | 171 | }
|
0 commit comments