Модуль:URL/tests

Бикипиэдьийэ диэн сиртэн ылыллыбыт

Для документации этого модуля может быть создана страница Модуль: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 | 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 | 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]')
end

return p