aboutsummaryrefslogtreecommitdiffstats
path: root/vim-mode/tests.pl
blob: 2a85b2971670cc44100a52f2441ea09948b19763 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl

# Must be run in a 80x24 terminal unless a fixed POE is released.


use strict;
use warnings;

use lib '../testing/blib/lib';

use Test::Irssi;


sub statusbar_mode {
    my ($test, $mode) = @_;

    $test->add_pattern_match(qr/^ \[\d{2}:\d{2}\] \[\] \[1\] \[$mode\]\s+$/,
        'window_sbar', "[$mode] in vim-mode statusbar");
}

my $tester = Test::Irssi->new
  (irssi_binary  => "irssi",
   irssi_homedir => "irssi");


my $test;


$test = $tester->new_test('insert-command-mode');

# Make sure irssi is finished - not entirely sure why this is necessary.
$test->add_delay(3);

# We start in insert mode.
statusbar_mode($test, 'Insert');

$test->add_input_sequence("\e");
$test->add_delay(1);
statusbar_mode($test, 'Command');

$test->add_input_sequence("i");
$test->add_delay(1);
statusbar_mode($test, 'Insert');

# Quit irssi, necessary to terminate the test.
$test->add_input_sequence("\n/quit\n");

$tester->run;