Module:Author/testcases

-- Unit tests for Module:Author. Click talk page to run tests. local p = require('Module:UnitTests') local Author = require('Module:Author')

function p:test_dates_supplied -- No dates. self:preprocess_equals(, , {nowiki=1}) -- Manual dates. self:preprocess_equals('', ' (Manual dates)', {nowiki=1}) -- Manual dates, but also birth and death dates (for categories). self:preprocess_equals('', ' (Manual dates)', {nowiki=1}) -- Exact years (both) self:preprocess_equals('', ' (1810–1890)', {nowiki=1}) -- Exact birth year and approximate death year self:preprocess_equals('', ' (1810 – c. 1890)', {nowiki=1}) -- Approximate birth year and unknown death year self:preprocess_equals('', ' (c. 1810 – ?)', {nowiki=1}) -- Multiple birth dates. self:preprocess_equals('', ' (1932/1933–)', {nowiki=1}) end

function p:test_dates_wikidata -- Both dates exact to the day. local janeAusten = 'Q36322' self:preprocess_equals('', ' (1775–1817)', {nowiki=1}) -- Dates not matching. self:preprocess_equals('', ' (1900–1817)', {nowiki=1}) self:preprocess_equals('', ' (1775–1817)', {nowiki=1}) self:preprocess_equals('', ' (1775–1817)', {nowiki=1}) -- Exact birth, century-only death. -- FIXME: Wikidata item is no longer representative -- local helenaFenwickDale = 'Q20204408' -- self:preprocess_equals('', ' (1854 – 20th century)', {nowiki=1}) -- Unknown birth, century-only death. -- FIXME: Wikidata item is no longer representative -- local johnBarr = 'Q16004141' -- self:preprocess_equals('', ' (? – 20th century)]', {nowiki=1}) -- Multiple dates of birth. Author:David self:preprocess_equals( '', ' (1039 BCE – 969 BCE)', {nowiki=1} ) -- Multiple death dates in the same year local johnKnox = 'Q189937' self:preprocess_equals( '', ' (c. 1514 – 1572)', {nowiki=1} ) -- Living person. self:preprocess_equals('', ' (1942–)', {nowiki=1}) -- No dates provided. Manu (Q178744, first human being in Hindu tradition). Only humans are called 'living' by default. self:preprocess_equals(, , {nowiki=1}) -- 4th century dates, where birth and death are the same. self:preprocess_equals('', ' (4th century)', {nowiki=1}) -- Floruit (with birth and death dates = 'unknown'). self:preprocess_equals('', ' (fl. 1735)', {nowiki=1}) -- Floruit with no death date. -- FIXME: Wikidata item is no longer representative -- self:preprocess_equals('', ' (fl. c. 509 BCE)', {nowiki=1}) -- First century BCE, where birth and death are the same. self:preprocess_equals('', ' (1st century BCE)', {nowiki=1}) self:preprocess_equals('', ' (fl. 1900s)', {nowiki=1}) -- Multiple floruit dates. -- FIXME: Wikidata item is no longer representative -- self:preprocess_equals('', ' (fl. 1875–1915)', {nowiki=1}) -- Floruit date more than 110 years ago and no death date. self:preprocess_equals('', ' (fl. 1521)', {nowiki=1}) self:preprocess_equals('', ' (1965–)', {nowiki=1}) end

function p:test_date -- Supplied years. self:preprocess_equals('', '1820') self:preprocess_equals('', 'c. 1820') self:preprocess_equals('', '1820s') self:preprocess_equals('', '1820?') self:preprocess_equals('', '1820?') self:preprocess_equals('', '1932/1933') -- Approximate birth date. self:preprocess_equals('', '19th century') self:preprocess_equals('', '17th century BCE')

-- Multiple dates of birth, Author:Alain de Lille. self:preprocess_equals('', '1110s/1114/1115') -- Exact death date, Author:Jane Austen. self:preprocess_equals('', '1817') -- Empty death date for living (JK Rowling) self:preprocess_equals(,  ) -- Empty wikidata_id parameter. self:preprocess_equals(, ) end

--[=[ Simple test for the wikicode string ]=] function p:test_categories_wikicode self:preprocess_equals(,		,		{nowiki=1}) self:preprocess_equals(,		,		{nowiki=1}) self:preprocess_equals(,		,		{nowiki=1}) end

return p