Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--
1637
-rw-r--r--
559
d='n45' href='#n45'>45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
// use helix_tui::{
//     backend::TestBackend,
//     buffer::Buffer,
//     layout::Rect,
//     style::{Color, Style},
//     text::Span,
//     widgets::{Block, Borders},
//     Terminal,
// };

// #[test]
// fn widgets_block_renders() {
//     let backend = TestBackend::new(10, 10);
//     let mut terminal = Terminal::new(backend).unwrap();
//     terminal
//         .draw(|f| {
//             let block = Block::default()
//                 .title(Span::styled("Title", Style::default().fg(Color::LightBlue)))
//                 .borders(Borders::ALL);
//             f.render_widget(
//                 block,
//                 Rect {
//                     x: 0,
//                     y: 0,
//                     width: 8,
//                     height: 8,
//                 },
//             );
//         })
//         .unwrap();
//     let mut expected = Buffer::with_lines(vec![
//         "┌Title─┐  ",
//         "│      │  ",
//         "│      │  ",
//         "│      │  ",
//         "│      │  ",
//         "│      │  ",
//         "│      │  ",
//         "└──────┘  ",
//         "          ",
//         "          ",
//     ]);
//     for x in 1..=5 {
//         expected.get_mut(x, 0).set_fg(Color::LightBlue);
//     }
//     terminal.backend().assert_buffer(&expected);
// }

// #[test]
// fn widgets_block_renders_on_small_areas() {
//     let test_case = |block, area: Rect, expected| {
//         let backend = TestBackend::new(area.width, area.height);
//         let mut terminal = Terminal::new(backend).unwrap();
//         terminal
//             .draw(|f| {
//                 f.render_widget(block, area);
//             })
//             .unwrap();
//         terminal.backend().assert_buffer(&expected);
//     };

//     let one_cell_test_cases = [
//         (Borders::NONE, "T"),
//         (Borders::LEFT, "│"),
//         (Borders::TOP, "T"),
//         (Borders::RIGHT, "│"),
//         (Borders::BOTTOM, "T"),
//         (Borders::ALL, "┌"),
//     ];
//     for (borders, symbol) in one_cell_test_cases.iter().cloned() {
//         test_case(
//             Block::default().title("Test").borders(borders),
//             Rect {
//                 x: 0,
//                 y: 0,
//                 width: 0,
//                 height: 0,
//             },
//             Buffer::empty(Rect {
//                 x: 0,
//                 y: 0,
//                 width: 0,
//                 height: 0,
//             }),
//         );
//         test_case(
//             Block::default().title("Test").borders(borders),
//             Rect {
//                 x: 0,
//                 y: 0,
//                 width: 1,
//                 height: 0,
//             },
//             Buffer::empty(Rect {
//                 x: 0,
//                 y: 0,
//                 width: 1,
//                 height: 0,
//             }),
//         );
//         test_case(
//             Block::default().title("Test").borders(borders),
//             Rect {
//                 x: 0,
//                 y: 0,
//                 width: 0,
//                 height: 1,
//             },
//             Buffer::empty(Rect {
//                 x: 0,
//                 y: 0,
//                 width: 0,
//                 height: 1,
//             }),
//         );
//         test_case(
//             Block::default().title("Test").borders(borders),
//             Rect {
//                 x: 0,
//                 y: 0,
//                 width: 1,
//                 height: 1,
//             },
//             Buffer::with_lines(vec![symbol]),
//         );
//     }
//     test_case(
//         Block::default().title("Test").borders(Borders::LEFT),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 4,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["│Tes"]),
//     );
//     test_case(
//         Block::default().title("Test").borders(Borders::RIGHT),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 4,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["Tes│"]),
//     );
//     test_case(
//         Block::default().title("Test").borders(Borders::RIGHT),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 4,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["Tes│"]),
//     );
//     test_case(
//         Block::default()
//             .title("Test")
//             .borders(Borders::LEFT | Borders::RIGHT),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 4,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["│Te│"]),
//     );
//     test_case(
//         Block::default().title("Test").borders(Borders::TOP),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 4,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["Test"]),
//     );
//     test_case(
//         Block::default().title("Test").borders(Borders::TOP),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 5,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["Test─"]),
//     );
//     test_case(
//         Block::default()
//             .title("Test")
//             .borders(Borders::LEFT | Borders::TOP),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 5,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["┌Test"]),
//     );
//     test_case(
//         Block::default()
//             .title("Test")
//             .borders(Borders::LEFT | Borders::TOP),
//         Rect {
//             x: 0,
//             y: 0,
//             width: 6,
//             height: 1,
//         },
//         Buffer::with_lines(vec!["┌Test─"]),
//     );
// }