-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.t
executable file
·73 lines (56 loc) · 1.69 KB
/
renderer.t
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
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
#!perl
# Cribbed from mojo's t/mojolicious/lite_app.t:
# Disable epoll, kqueue and IPv6
BEGIN { $ENV{MOJO_POLL} = $ENV{MOJO_NO_IPV6} = 1 }
use Test::More;
plan tests => 15;
use Mojolicious 0.999930;
use Mojolicious::Lite;
use Test::Mojo;
app->log->level('fatal');
plugin 'write_excel';
get '/demo.xls' => sub {
shift->render(
handler => 'xls',
heading => [qw(Firstname Middle LastName)],
result =>
[[qw(Zak B Elep)], [qw(Joel T Tanangonan)], [qw(Jerome S Gotangco)],],
);
};
get '/demo_without_heading.xls' => sub {
shift->render(
handler => 'xls',
result => [[qw(foo bar baz)], [qw(lol wut bbq)], [qw(kick ass module)],],
);
};
get '/demo_with_column_width.xls' => sub {
shift->render(
handler => 'xls',
result => [],
settings => {column_width => {'A:A' => 10, 'B:B' => 25, 'C:D' => 40}},
);
};
get '/demo_with_broken_column_width_1.xls' => sub {
shift->render(
handler => 'xls',
result => [],
settings => {column_width => undef},
);
};
get '/demo_with_app_helper.xls' => sub {
shift->render_xls(
result => [[qw(foo bar baz)], [qw(lol wut bbq)], [qw(kick ass module)],],
);
};
# Test
my $t = Test::Mojo->new;
$t->get_ok('/demo.xls')->status_is(200)
->content_type_is('application/vnd.ms-excel');
$t->get_ok('/demo_without_heading.xls')->status_is(200)
->content_type_is('application/vnd.ms-excel');
$t->get_ok('/demo_with_column_width.xls')->status_is(200)
->content_type_is('application/vnd.ms-excel');
$t->get_ok('/demo_with_broken_column_width_1.xls')->status_is(500)
->content_type_is('text/html;charset=UTF-8');
$t->get_ok('/demo_with_app_helper.xls')->status_is(200)
->content_type_is('application/vnd.ms-excel');