2016-07-21 13:47:14 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use Test::Deep;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'jsonvalidator';
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
# Build a structured answer that should match the response from the
|
|
|
|
# Perl file.
|
|
|
|
sub build_structured_answer {
|
|
|
|
my @test_params = @_;
|
|
|
|
|
2016-07-21 14:31:53 -07:00
|
|
|
return '',
|
2016-07-21 13:47:14 -07:00
|
|
|
structured_answer => {
|
|
|
|
|
2016-07-21 14:31:53 -07:00
|
|
|
id => "json_validator",
|
|
|
|
|
2016-07-21 13:47:14 -07:00
|
|
|
data => {
|
2016-07-21 14:31:53 -07:00
|
|
|
title => 'JSON Validator',
|
|
|
|
subtitle => 'Enter your JSON below and click on the button to check if it\'s valid'
|
2016-07-21 13:47:14 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
templates => {
|
|
|
|
group => 'text',
|
2016-07-21 14:31:53 -07:00
|
|
|
item => 0,
|
|
|
|
options => {
|
|
|
|
content => 'DDH.json_validator.content'
|
|
|
|
}
|
2016-07-21 13:47:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use this to build expected results for your tests.
|
|
|
|
sub build_test { test_zci(build_structured_answer(@_)) }
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[qw( DDG::Goodie::JSONValidator )],
|
2016-07-21 14:31:53 -07:00
|
|
|
|
|
|
|
'json validator' => build_test(),
|
2016-07-21 13:47:14 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|