Модуль:URL/tests: различия между версиями
Материал из ChronoWiki
Перейти к навигацииПерейти к поиску (тест на http:// внутри ссылки) |
Lirik (обсуждение | вклад) м (1 версия импортирована) |
(нет различий)
|
Текущая версия на 00:23, 4 января 2020
Для документации этого модуля может быть создана страница Модуль: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]{{ref-en}} }}', '[http://example.com title]' .. self.frame:expandTemplate{ title = 'ref-en' } ) 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/…]' ) 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/…]' ) self:preprocess_equals('{{#invoke:URL | formatUrl | [https://web.archive.org/web/20070520014853/http://example.com/] | length = 25 }}', '[https://web.archive.org/web/20070520014853/http://example.com/ web.archive.org/web/2007…]' ) self:preprocess_equals('{{#invoke:URL | formatUrl | [http://example.com example.com]<br>[http://www.example.ru example.ru] }}', '[http://example.com example.com]<br>[http://www.example.ru example.ru]' ) self:preprocess_equals('{{#invoke:URL | formatUrl | [[Site]] }}', '[[Site]]' ) end return p