Module:YouTube/Test
[voir] [modifier] [historique] [purger]
Ce module Lua est utilisé par le modèle {{YouTube}}.
Page à prévisualiser pour vérifier les modifications : Discussion module:YouTube/Test.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local p = require('Module:UnitTests')
function p:test_01_timestamp()
self:preprocess_equals_many('{{#invoke:YouTube|timestamp|', '}}', {
{'1230s' , '1230s'},
{'20m30s' , '1230s'},
{'1h20m30s' , '4830s'},
{'01h020m030s', '4830s'}, -- leading zeroes
{'0h00m00s' , '0s'}, -- values zero
{'30s20m1h' , '4830s'}, -- unordered parts
{'1h30s' , '3630s'}, -- hours and seconds but no minutes
{'1230' , '1230s'}, -- integer
{'20:30' , '1230s'}, -- « mm:ss » format
{'0:30' , '30s'}, -- « mm:ss » format, with zero minutes
{'1:20:30' , '4830s'}, -- « hh:mm:ss » format
{'1:00:30' , '3630s'}, -- « hh:mm:ss » format, with zero minutes
{'0s' , '0s'}, -- timestamp at zero seconds ("0s")
{'0:00' , '0s'}, -- timestamp at zero seconds ("0:00")
{'foobar' , 'foobar'}, -- unrecognized input
{'' , ''},
})
end
function p:test_02_libelle()
local function part(num, text, title)
return num .. '\194\160' .. '<abbr class="abbr" title="' .. title .. '">' .. text .. '</abbr>'
end
self:preprocess_equals_many('{{#invoke:YouTube|libelle|', '}}', {
{'1230s' , part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'20m30s' , part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'1h20m30s' , part(1, 'h', 'heure') .. '\194\160' .. part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'01h020m030s', part(1, 'h', 'heure') .. '\194\160' .. part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'0h00m00s' , part(0, 's', 'seconde')},
{'30s20m1h' , part(1, 'h', 'heure') .. '\194\160' .. part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'1h30s' , part(1, 'h', 'heure') .. '\194\160' .. part(30, 's', 'secondes')},
{'1230' , part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'20:30' , part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'0:30' , part(30, 's', 'secondes')},
{'1:20:30' , part(1, 'h', 'heure') .. '\194\160' .. part(20, 'min', 'minutes') .. '\194\160' .. part(30, 's', 'secondes')},
{'1:00:30' , part(1, 'h', 'heure') .. '\194\160' .. part(30, 's', 'secondes')},
{'0s' , part(0, 's', 'seconde')},
{'0:00' , part(0, 's', 'seconde')},
{'foobar' , 'foobar'},
{'' , ''},
})
end
return p