Simon, you mentioned testing, and I was mentioning it to Johan. Is
there a JS unit testing framework that’s decent that you use?
I got to thinking as I working on a Python test that if we used
YAML/JSON (e.g. YAML that is also valid JSON) we could use the same
test data. It may not be necessary, though (?).
Here, BTW, is a good test for whether you can get correct grouping and
sorting, and substitution, for author-year citations.
! /usr/bin/env python
from citeproc import CiteProc
class TestReferenceList:
def test_setup():
data = [
{
"type": "Article"
"title": "Some Title",
"year": "1999",
"author": [{"given_name":"Jane", "family_name":"Doe"}]
},
{
"type": "NewsArticle"
"title": "News Title",
"year": "2002",
"periodical": {"title":"Newsweek"}
},
{
"type": "Article"
"title": "XYZ",
"year": "1999",
"author": [
{"given_name":"Jane", "family_name":"Doe"},
{"given_name":"Susan", "family_name":"Smith"}
]
},
{
"type": "NewsArticle"
"title": "Second News Title",
"year": "2002",
"periodical": {"title":"Newsweek"}
},
{
"type": "Article"
"title": "Another Title",
"year": "1999",
"author": [{"given_name":"Jane", "family_name":"Doe"}]
}
]
list = ReferenceList(style="apa", data=data)
# first test basic author-year grouping and sorting
def test_reference_grouping_sorting():
# use itertools groupby?
assert list[1].suffix == "b"
assert list[2].suffix == nil
# test that substitution works properly where there is no author
def test_reference_grouping_sorting_substitution():
assert list[3].suffix == "a"