You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/04/03 11:53:23 UTC
[incubator-annotator] 08/09: Add tests for stringify
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch fragment-tests
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 6b14a01f082134cc436fef1360e9ea101e645491
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Apr 3 12:57:12 2020 +0200
Add tests for stringify
---
packages/fragment-identifier/test/index.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/packages/fragment-identifier/test/index.js b/packages/fragment-identifier/test/index.js
index 947e03f..cfba7f9 100644
--- a/packages/fragment-identifier/test/index.js
+++ b/packages/fragment-identifier/test/index.js
@@ -29,6 +29,16 @@ const specExamples = Object.fromEntries(Object.entries(specExamplesRaw).map(
[name, { fragId: uri.split('#')[1], selector, state }]
));
+const specialCasesToStringify = {
+ 'Value with parentheses (to be percent-encoded)': {
+ fragId: 'selector(type=TextQuoteSelector,exact=example%20%28with%20parentheses%29)',
+ selector: {
+ type: 'TextQuoteSelector',
+ exact: 'example (with parentheses)',
+ },
+ },
+};
+
describe('stringify', () => {
// Test examples in the spec, ignoring their URI encoding
for (const [name, example] of Object.entries(specExamples)) {
@@ -40,6 +50,13 @@ describe('stringify', () => {
);
});
}
+
+ for (const [name, example] of Object.entries(specialCasesToStringify)) {
+ it(`should properly stringify: '${name}'`, () => {
+ const result = stringify(example.selector || example.state);
+ assert.equal(result, example.fragId);
+ });
+ }
});
const specialCasesToParse = {