ماڈیول:URL/tests
Documentation for this module may be created at ماڈیول: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]')
end
return p