소스 검색

Tests for Git rendering

Benjamin Sago 8 년 전
부모
커밋
9642f69ce7
1개의 변경된 파일55개의 추가작업 그리고 0개의 파일을 삭제
  1. 55 0
      src/output/render/mod.rs

+ 55 - 0
src/output/render/mod.rs

@@ -97,3 +97,58 @@ impl f::Git {
         }
     }
 }
+
+
+#[cfg(test)]
+pub mod test {
+    use output::details::Details;
+    use output::cell::{TextCell, DisplayWidth};
+    use fs::fields as f;
+
+    use ansi_term::Colour::*;
+
+
+    #[test]
+    fn git_blank() {
+        let mut details = Details::default();
+        details.colours.punctuation = Fixed(44).normal();
+
+        let stati = f::Git {
+            staged:   f::GitStatus::NotModified,
+            unstaged: f::GitStatus::NotModified,
+        };
+
+        let expected = TextCell {
+            width: DisplayWidth::from(2),
+            contents: vec![
+                Fixed(44).paint("-"),
+                Fixed(44).paint("-"),
+            ].into(),
+        };
+
+        assert_eq!(expected, stati.render(&details.colours).into())
+    }
+
+    #[test]
+    fn git_new_changed() {
+        let mut details = Details::default();
+        details.colours.git.new = Red.normal();
+        details.colours.git.modified = Purple.normal();
+
+        let stati = f::Git {
+            staged:   f::GitStatus::New,
+            unstaged: f::GitStatus::Modified,
+        };
+
+        let expected = TextCell {
+            width: DisplayWidth::from(2),
+            contents: vec![
+                Red.paint("N"),
+                Purple.paint("M"),
+            ].into(),
+        };
+
+        assert_eq!(expected, stati.render(&details.colours).into())
+    }
+
+}