Jump to content

Module:URL/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dcoetzee (talk | contribs) at 22:43, 26 February 2013 (Created page with '-- Unit tests for Module:URL. Click talk page to run tests. local p = require('Module:UnitTests') function p:test_url() self:preprocess_equals_many('{{...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
-- Unit tests for [[Module:URL]]. Click talk page to run tests.
local p = require('Module:UnitTests')
 
function p:test_url()
    self:preprocess_equals_many('{{#invoke:URL|url|', '}}', {
        {'', '{{URL|example.com|optional display text}}'},
        {' EXAMPLE.com ', 'example.com'},
        {' example.com ', 'example.com'},
        {' www.example.com ', 'www.example.com'},
        {' http://www.example.com ', 'www.example.com'},
        {' https://www.example.com ', 'www.example.com'},
        {' ftp://www.example.com ', 'www.example.com'},
        {' ftp://ftp.example.com ', 'ftp.example.com'},
        {' http://www.example.com/ ', 'www.example.com'},
        {' http://www.example.com/path ', 'www.example.com/path'},
        {' www.example.com/foo ', 'www.example.com/foo'},
        {' http://www.example.com/foo | link ', 'link'},
        {' www.example.com/foo | link ', 'link'},
        {' http://www.example.com/path/ ', 'www.example.com/path/'},
        {' www.example.com/foo/ ', 'www.example.com/foo/'},
        {' 1=http://www.example.com/path?section=17 ', 'www.example.com/path?section=17'},
        {' 1=www.example.com/foo?page=42 ', 'www.example.com/foo?page=42'},
        {' http://www.example.com/foo/ | link ', 'link'},
        {' www.example.com/foo/ | link ', 'link'},
    })
end

return p