From c02f9ddf963d8dc763929ede4aa87cc0742ef70a Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Thu, 22 Oct 2020 01:10:24 +0200 Subject: [PATCH] test: add more tests See https://github.com/citation-js/bibtex-parser-experiments/issues/3#issuecomment-713915888 --- README.md | 4 ++++ test/fixtures/features.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/README.md b/README.md index 1fbad4d..c45d728 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ see also [the fixture file](test/fixtures/features.js). | entry with trailing comma | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | string key with colon | ✘ | ✓ | ✘ | ✓ | ✘ | ✓ | | entry key with colon | ✓ | ✓ | ✓ | ✘ | ✘ | ✓ | +| entry value with annotation | | | | | | | | entry label with number | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | entry label with colon | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | entry label with double quotes | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | @@ -165,8 +166,11 @@ see also [the fixture file](test/fixtures/features.js). | entry value with uri fields | | ✓ | | | | | | entry value with pre-encoded uri fields | ✓ | ✓ | ✓ | | | ✓ | | entry value with diacritics | ✘ | ✓ | ✘ | ✘ | ✘ | ✓ | +| entry value with escapes | ✘ | ✓ | ✘ | ✘ | ✘ | ✘ | | entry value with sub/superscript | ✘ | ✓ | ✘ | ✘ | ✘ | ✓ | | entry value with multi-argument commands | ✘ | ✘ | ✘ | ✘ | ✘ | ✓ | +| entry value with verbatim-argument commands | ✘ | ✘ | ✘ | ✘ | ✘ | ✓ | +| entry value with unbracketed-argument commands | ✘¹ | ✘¹ | ✘¹ | ✘¹ | ✘¹ | ✓ | | TODO | | | | | | | | string with lowercase type | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | | string with mixed-case type | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | diff --git a/test/fixtures/features.js b/test/fixtures/features.js index c0a59cd..0e46383 100644 --- a/test/fixtures/features.js +++ b/test/fixtures/features.js @@ -44,6 +44,24 @@ export default { input: `@book{a, a:a = "foo" }`, output: [{ type: 'book', id: 'a', properties: { 'a:a': 'foo' } }] }, + 'entry value with annotation': { + input: `@MISC{ann1, + AUTHOR = {Last1, First1 and Last2, First2 and Last3, First3}, + AUTHOR+an = {1:family=student;2=corresponding} +}`, + output: { + id: 'ann1', + properties: { + author: [ + { family: 'Last1', given: 'First1' }, + { family: 'Last2', given: 'First2' }, + { family: 'Last3', given: 'First3' } + ] + }, + type: 'misc' + }, + only: 'biblatex' + }, // LABELS 'entry label with number': { @@ -273,6 +291,27 @@ export default { input: `@article{test, title = {$\\frac 1 2$ and $\\frac{n}{2}$}}`, output: [{ id: 'test', properties: { title: '½ and ⁿ⁄₂' }, type: 'article'}] }, + 'entry value with verbatim-argument commands': { + input: `@article{test, title = "\\href{http://example.org/{id}}{url}"}`, + output: [{ + id: 'test', + properties: { + title: 'http://example.org/{id}' + }, + type: 'article' + }] + }, + 'entry value with unbracketed-argument commands': { + input: `@article{test, title = {Stability analysis and \\emph optimization}}`, + output: [{ + id: 'test', + properties: { + title: 'Stability analysis and optimization' + }, + type: 'article' + }], + gimmick: 'REPRESENTATION' + }, // TODO 'TODO': { only: 'display'