Skip to content

[WIP] Unit tests #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b903c82
Unit tests for microformat and property names
JKingweb Jul 7, 2023
246d842
Whitespace-related name tests
JKingweb Jul 7, 2023
971c603
Tests for multiple root types on one element
JKingweb Jul 7, 2023
a87f810
Add negative tests for property names based on pefix
JKingweb Jul 7, 2023
384b73a
Document common behaviour of duplicate properties
JKingweb Jul 7, 2023
0a3e9d4
Split underspecified behaviour from certain stuff
JKingweb Jul 8, 2023
8b5b80a
Tests for p-properties
JKingweb Jul 8, 2023
9b0a510
Pre-empt all possible implied properties
JKingweb Jul 8, 2023
9e01ff0
Tests for u-properties
JKingweb Jul 8, 2023
dcc26ce
Add missing "else" u- test
JKingweb Jul 8, 2023
fd28ab7
Tests for dt-properties and e-properties
JKingweb Jul 9, 2023
4e09cf6
More negative tests for property parsing
JKingweb Jul 9, 2023
1de63e0
Implied name tests
JKingweb Jul 9, 2023
904d24c
Make explicit when properties are not part of test
JKingweb Jul 9, 2023
3c4fcab
Add no-trim tests for implied name
JKingweb Jul 9, 2023
bc48625
Compress whitespace
JKingweb Jul 10, 2023
7c42894
Tests for implied photo
JKingweb Jul 10, 2023
e310fa4
Fix various test errors
JKingweb Jul 10, 2023
de96b69
Tests for implied url
JKingweb Jul 10, 2023
204a0c5
VCP tests for p-properties
JKingweb Jul 11, 2023
5639c6a
VCP tests for u-properties
JKingweb Jul 12, 2023
f1d4be6
More p- and u- VCP tests
JKingweb Jul 12, 2023
461803e
Restore accidentally deleted test
JKingweb Jul 12, 2023
15a2179
VCP tests for dt-properties
JKingweb Jul 14, 2023
c97a416
Use less problematic date format
JKingweb Jul 14, 2023
244dbe9
Add special-case elements for VCP date parsing
JKingweb Jul 14, 2023
7b7b252
Whitespace cleanup
JKingweb Jul 14, 2023
69c7dcf
VCP test for e-properties
JKingweb Jul 14, 2023
96cc6f6
Tests for microformat nesting in its sudry forms
JKingweb Jul 18, 2023
a69ed8d
Use "test" prefix for roots to avoid confusion
JKingweb Jul 18, 2023
b7f9da2
Fix some test errors
JKingweb Jul 22, 2023
2c2840c
Ensure output is the same with either textContent
JKingweb Jul 22, 2023
cd4eaee
Add a README file for unit tests
JKingweb Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/microformats-v2-unit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Microformats v2 unit tests

This directory contains a set of "unit tests" for microformats parsers. Where other tests seek to demonstrate correct behaviour for real-world documents, these tests are purely synthetic, and aim to test individual parsing features in detail.

## Design principles

Tests adhere to the following design principles. New additions to this test series should follow these principles wherever possible, and document deviations in HTML comments where applicable.

- As much as possible each file should test only one parsing feature. Due to the requirements of microformats parsing this can often be difficult to accomplish. In particular, the following should be avoided in test output:
- Implied properties: where the parser would imply a `p-name` or other property, add an explicit one
- Text trimming: Any text output should avoid inner or outer whitespace which the traditional or [more aggressive](https://microformats.org/wiki/textcontent-parsing) triming algorithms would remove. At the very least, tests should pass regardless of which algorithm is used
- URL normalization: URLs should be kept simple, as the details of expected normalization are undefined as of this writing
- Where the specification is silent or unclear as to the expected behaviour of a feature but most implementations agree, tests should be placed into a file named beginning with `tentative-` e.g. `tentative-some-feature.html` to allow implementations to easily skip these tests if they do not implement the majority behaviour. Such files should include HTML comments with explanatory details and references to any relevant GitHub issues or other discussion
- Top-level microformat types should include "test" within their name. For example, use `h-test-explicit` rather than `h-explicit`
- Top-level microformat types should be unique per file, so that failing tests can have unique identifiers. In other words, do not use `h-test` for every microformat; instead use `h-1-test` and `h-2-test`, or even better `h-test-with-feature` and `h-test-without-feature`
- Test failure should be indicated with the inclusion of "Invalid" in the output, wherever possible. Test success may be indicated with the inclusion of the text "Valid", but other text may be used where suitable
- Where the parser is expected to trim attribute values, the text "Do Trim" should be used in the output. Conversely, where the parser is expected not to trim attribute values, the text " No Trim " should be used in the output
- The implied base URL is `http://example.test`. The `example.test` domain is used instead of `example.com` as in other tests since `example.com` is an actual host on the Internet and implementations might conceivably communicate with it automatically. This may change if consensus emerges that `example.com` is nevertheless preferred

## Setting up the tests

Test set-up is the same as for the other test sets, with the exception that the base URL is `http://example.test`. Partial parser implementations may wish to execute tests in a particular orderto test basic features before more complex ones:

1. Microformat tests in `names`
2. Property tests in `names`
3. Tests in `properties`
4. Tests in `implied`
5. Tests in `value`
6. Tests in `nested`
233 changes: 233 additions & 0 deletions tests/microformats-v2-unit/implied/implied-name.html

Large diffs are not rendered by default.

Loading