Module:Official website/testcases: Difference between revisions
Appearance
Content deleted Content added
test |
update |
||
Line 3: | Line 3: | ||
function p:test_module() |
function p:test_module() |
||
self:preprocess_equals_many('{{#invoke:Official website|main | ', ' }}', { |
|||
{ |
|||
'example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'//example.com', |
|||
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'', |
|||
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>' |
|||
}, |
|||
{ |
|||
'www.example.com/path?section=96', |
|||
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>' |
|||
}, |
|||
{ |
|||
'1= www.example.com/path?section=96', |
|||
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'url= example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'URL= example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http:/example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com/', |
|||
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://www.example.com:80', |
|||
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'https://example.com', |
|||
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'ftp://example.com', |
|||
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com | Example', |
|||
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>' |
|||
}, |
|||
{ |
|||
'url= http://example.com |name= Example', |
|||
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com |format= flash', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>' |
|||
}, |
|||
{ |
|||
'http://example.com |mobile= http://m.example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)' |
|||
}, |
|||
} ) |
|||
end |
|||
function p:test_module_nowiki() |
|||
self:preprocess_equals_many('{{#invoke:Official website|main | ', ' }}', { |
self:preprocess_equals_many('{{#invoke:Official website|main | ', ' }}', { |
||
{ |
{ |
||
Line 154: | Line 227: | ||
}, |
}, |
||
} ) |
} ) |
||
end |
|||
function p:test_sandbox_nowiki() |
|||
self:preprocess_equals_many('{{#invoke:Official website/sandbox|main | ', ' }}', { |
|||
{ |
|||
'example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'//example.com', |
|||
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'', |
|||
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>' |
|||
}, |
|||
{ |
|||
'www.example.com/path?section=96', |
|||
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>' |
|||
}, |
|||
{ |
|||
'1= www.example.com/path?section=96', |
|||
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'url= example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'URL= example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http:/example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com/', |
|||
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://www.example.com:80', |
|||
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'https://example.com', |
|||
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'ftp://example.com', |
|||
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com | Example', |
|||
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>' |
|||
}, |
|||
{ |
|||
'url= http://example.com |name= Example', |
|||
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>' |
|||
}, |
|||
{ |
|||
'http://example.com |format= flash', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>' |
|||
}, |
|||
{ |
|||
'http://example.com |mobile= http://m.example.com', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)' |
|||
}, |
|||
{ |
|||
'http://example.jp | lang= jp', |
|||
'<span class="official-website"><span class="url">[http://example.jp Official website]</span></span> <span class="languageicon">(in Japanese)</span>' |
|||
}, |
|||
{ |
|||
'http://example.com | lang= en', |
|||
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span class="languageicon">(in English)</span>' |
|||
}, |
|||
},{nowiki=1}) |
|||
end |
end |
||
Revision as of 03:49, 9 August 2018
![]() | This is the test cases page for the module Module:Official website. Results of the test cases. |
local p = require('Module:UnitTests')
function p:test_module()
self:preprocess_equals_many('{{#invoke:Official website|main | ', ' }}', {
{
'example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'//example.com',
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>'
},
{
'',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'www.example.com/path?section=96',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'1= www.example.com/path?section=96',
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>'
},
{
'url= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'URL= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http:/example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com/',
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>'
},
{
'http://www.example.com:80',
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>'
},
{
'https://example.com',
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>'
},
{
'ftp://example.com',
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>'
},
{
'http://example.com | Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'url= http://example.com |name= Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'http://example.com |format= flash',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>'
},
{
'http://example.com |mobile= http://m.example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)'
},
} )
end
function p:test_module_nowiki()
self:preprocess_equals_many('{{#invoke:Official website|main | ', ' }}', {
{
'example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'//example.com',
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>'
},
{
'',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'www.example.com/path?section=96',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'1= www.example.com/path?section=96',
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>'
},
{
'url= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'URL= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http:/example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com/',
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>'
},
{
'http://www.example.com:80',
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>'
},
{
'https://example.com',
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>'
},
{
'ftp://example.com',
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>'
},
{
'http://example.com | Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'url= http://example.com |name= Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'http://example.com |format= flash',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>'
},
{
'http://example.com |mobile= http://m.example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)'
},
},{nowiki=1})
end
function p:test_sandbox()
self:preprocess_equals_many('{{#invoke:Official website/sandbox|main | ', ' }}', {
{
'example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'//example.com',
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>'
},
{
'',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'www.example.com/path?section=96',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'1= www.example.com/path?section=96',
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>'
},
{
'url= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'URL= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http:/example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com/',
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>'
},
{
'http://www.example.com:80',
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>'
},
{
'https://example.com',
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>'
},
{
'ftp://example.com',
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>'
},
{
'http://example.com | Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'url= http://example.com |name= Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'http://example.com |format= flash',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>'
},
{
'http://example.com |mobile= http://m.example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)'
},
{
'http://example.jp | lang= jp',
'<span class="official-website"><span class="url">[http://example.jp Official website]</span></span> <span class="languageicon">(in Japanese)</span>'
},
{
'http://example.com | lang= en',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span class="languageicon">(in English)</span>'
},
} )
end
function p:test_sandbox_nowiki()
self:preprocess_equals_many('{{#invoke:Official website/sandbox|main | ', ' }}', {
{
'example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'//example.com',
'<span class="official-website"><span class="url">[//example.com Official website]</span></span>'
},
{
'',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'www.example.com/path?section=96',
'<strong class="error">No URL found. Please specify a URL here or add one to Wikidata.</strong>'
},
{
'1= www.example.com/path?section=96',
'<span class="official-website"><span class="url">[http://www.example.com/path?section=96 Official website]</span></span>'
},
{
'url= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'URL= example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http:/example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span>'
},
{
'http://example.com/',
'<span class="official-website"><span class="url">[http://example.com/ Official website]</span></span>'
},
{
'http://www.example.com:80',
'<span class="official-website"><span class="url">[http://www.example.com:80 Official website]</span></span>'
},
{
'https://example.com',
'<span class="official-website"><span class="url">[https://example.com Official website]</span></span>'
},
{
'ftp://example.com',
'<span class="official-website"><span class="url">[ftp://example.com Official website]</span></span>'
},
{
'http://example.com | Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'url= http://example.com |name= Example',
'<span class="official-website"><span class="url">[http://example.com Example]</span></span>'
},
{
'http://example.com |format= flash',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span style="font-size:0.95em; font-size:90%; color:#555">(Requires [[Adobe Flash Player]])</span>'
},
{
'http://example.com |mobile= http://m.example.com',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> (<span class="url">[http://m.example.com Mobile]</span>)'
},
{
'http://example.jp | lang= jp',
'<span class="official-website"><span class="url">[http://example.jp Official website]</span></span> <span class="languageicon">(in Japanese)</span>'
},
{
'http://example.com | lang= en',
'<span class="official-website"><span class="url">[http://example.com Official website]</span></span> <span class="languageicon">(in English)</span>'
},
},{nowiki=1})
end
return p