Bug 33625: Add test
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
25f8581c0d
commit
0192bb0cb8
1 changed files with 26 additions and 4 deletions
|
@ -20,17 +20,17 @@ use File::Slurp qw( read_file );
|
|||
use File::Find;
|
||||
use FindBin();
|
||||
use Data::Dumper qw( Dumper );
|
||||
use Test::More tests => 1;
|
||||
use Test::More tests => 2;
|
||||
|
||||
my $vue_dir = "$FindBin::Bin/../koha-tmpl/intranet-tmpl/prog/js/vue";
|
||||
|
||||
my @files;
|
||||
sub wanted {
|
||||
sub wanted_vue {
|
||||
my $name = $File::Find::name;
|
||||
push @files, $name
|
||||
if $name =~ /\.vue$/;
|
||||
}
|
||||
find({ wanted => \&wanted, no_chdir => 1 }, $vue_dir);
|
||||
find({ wanted => \&wanted_vue, no_chdir => 1 }, $vue_dir);
|
||||
|
||||
my @not_tidy;
|
||||
foreach my $filepath (@files) {
|
||||
|
@ -42,4 +42,26 @@ foreach my $filepath (@files) {
|
|||
}
|
||||
}
|
||||
|
||||
is(scalar(@not_tidy), 0, 'No vue file should be messy') or diag Dumper \@not_tidy;
|
||||
is(scalar(@not_tidy), 0, 'No .vue file should be messy') or diag Dumper \@not_tidy;
|
||||
|
||||
@files = ();
|
||||
sub wanted_js_ts {
|
||||
my $name = $File::Find::name;
|
||||
push @files, $name
|
||||
if ( $name =~ /\.js$/
|
||||
|| $name =~ /\.ts$/ )
|
||||
&& $name !~ m{koha-tmpl/intranet-tmpl/prog/js/vue/dist}; # Exclude dist
|
||||
}
|
||||
find({ wanted => \&wanted_js_ts, no_chdir => 1 }, $vue_dir);
|
||||
|
||||
@not_tidy = ();
|
||||
foreach my $filepath (@files) {
|
||||
chomp $filepath;
|
||||
my $tidy = qx{yarn --silent run prettier --trailing-comma es5 --arrow-parens avoid $filepath};
|
||||
my $content = read_file $filepath;
|
||||
if ( $content ne $tidy ) {
|
||||
push @not_tidy, $filepath;
|
||||
}
|
||||
}
|
||||
|
||||
is(scalar(@not_tidy), 0, 'No js file from vue directory should be messy') or diag Dumper \@not_tidy;
|
||||
|
|
Loading…
Reference in a new issue