Module:URL/tests
Jump to navigation
Jump to search
Documentation for this module may be created at Module:URL/tests/doc
-- Unit tests for [[Module:URL]]. Click talk page to run tests.
local p = require( 'Module:UnitTests' )
function p:test_formatUrl()
self:preprocess_equals( '{{#invoke:URL | formatUrl | }}', '' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | EXAMPLE.com }}', '[http://EXAMPLE.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | example.com }}', '[http://example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | www.example.com }}', '[http://www.example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://www.example.com }}', '[http://www.example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://пример.рф }}', '[http://пример.рф пример.рф]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | https://www.example.com }}', '[https://www.example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | ftp://www.example.com }}', '[ftp://www.example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | ftp://ftp.example.com }}', '[ftp://ftp.example.com ftp.example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://www.example.com/ }}', '[http://www.example.com/ example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | //ftp.example.com }}', '[//ftp.example.com ftp.example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | //www.example.com/ }}', '[//www.example.com/ example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | www.example.com/foo }}', '[http://www.example.com/foo example.com/foo]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://www.example.com/foo }}', '[http://www.example.com/foo example.com/foo]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://sub.example.com/foo/bar }}', '[http://sub.example.com/foo/bar sub.example.com/foo/bar]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | example.com?a }}', '[http://example.com?a example.com?a]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://sub.example.com/foo/bar?a }}', '[http://sub.example.com/foo/bar?a sub.example.com/foo/bar?a]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | example.com | title }}', '[http://example.com title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | example.com?a | title }}', '[http://example.com?a title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://sub.example.com/foo/bar | title }}', '[http://sub.example.com/foo/bar title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://sub.example.com/foo/bar?a | title }}', '[http://sub.example.com/foo/bar?a title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | [http://example.com] }}', '[http://example.com example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | [http://example.com title] }}', '[http://example.com title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | [http://пример.рф пример] }}', '[http://пример.рф пример]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | [http://example.com old title] | title }}', '[http://example.com title]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | email@example.com }}', '[mailto:email@example.com email@example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | mailto:email@example.com }}', '[mailto:email@example.com email@example.com]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | [http://example.com title] {{ok}} }}', '[http://example.com title] ' .. self.frame:expandTemplate{ title = 'ok' } )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://example.com/very/long/path/index.html | length = 25 }}', '[http://example.com/very/long/path/index.html example.com/very/long/pa…]' )
self:preprocess_equals( '{{#invoke:URL | formatUrl | http://very.long.domain.example.com/index.html | length = 25 }}', '[http://very.long.domain.example.com/index.html very.long.domain.example.com/…]' )
end
return p