@natlibfi/ekirjasto-opds-feed-parser 0.0.0-post.148 → 0.0.0-post.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +10 -6
- package/.github/CODEOWNERS +0 -4
- package/.github/pull_request_template.md +0 -12
- package/.github/workflows/release.yml +0 -102
- package/.github/workflows/test.yml +0 -23
- package/requirements-ci.txt +0 -1
- package/test/accessibility_parser_test.ts +0 -450
- package/test/availability_parser_test.ts +0 -32
- package/test/category_parser_test.ts +0 -30
- package/test/contributor_parser_test.ts +0 -44
- package/test/copies_parser_test.ts +0 -30
- package/test/entry_parser_test.ts +0 -272
- package/test/feed_parser_test.ts +0 -244
- package/test/files/accessibility.xml +0 -13
- package/test/files/acquisition.xml +0 -426
- package/test/files/entry.xml +0 -43
- package/test/files/navigation.xml +0 -56
- package/test/holds_parser_test.ts +0 -30
- package/test/indirect_acquisition_parser_test.ts +0 -46
- package/test/link_parser_test.ts +0 -324
- package/test/namespace_parser_test.ts +0 -41
- package/test/opds_parser_test.ts +0 -153
- package/test/price_parser_test.ts +0 -30
- package/test/series_parser_test.ts +0 -30
- package/tsconfig.json +0 -15
- package/tslint.json +0 -54
- package/typings.json +0 -8
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@natlibfi/ekirjasto-opds-feed-parser",
|
|
3
3
|
"description": "E-kirjasto OPDS feed parser",
|
|
4
|
-
"version": "0.0.0-post.
|
|
4
|
+
"version": "0.0.0-post.149",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "The National Library of Finland"
|
|
7
7
|
},
|
|
@@ -15,18 +15,22 @@
|
|
|
15
15
|
"homepage": "https://github.com/NatLibFi/ekirjasto-opds-feed-parser",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git@github.com
|
|
19
|
-
},
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/NatLibFi/ekirjasto-opds-feed-parser/issues"
|
|
18
|
+
"url": "git+ssh://git@github.com/NatLibFi/ekirjasto-opds-feed-parser.git"
|
|
22
19
|
},
|
|
23
20
|
"engines": {
|
|
24
21
|
"node": ">=20"
|
|
25
22
|
},
|
|
26
23
|
"main": "lib/src/index.js",
|
|
27
24
|
"typings": "lib/src/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/src/**/*",
|
|
27
|
+
"CHANGELOG",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
28
31
|
"scripts": {
|
|
29
|
-
"
|
|
32
|
+
"prepare": "rm -rf lib && tsc",
|
|
33
|
+
"prepublishOnly": "npm test",
|
|
30
34
|
"lint": "tslint -c tslint.json src/*.ts test/*.ts",
|
|
31
35
|
"test": "rm -rf lib && npm run lint && tsc && mocha lib/test/*.js"
|
|
32
36
|
},
|
package/.github/CODEOWNERS
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
## Description
|
|
2
|
-
<!--- Provide a brief overview of what this pull request accomplishes -->
|
|
3
|
-
|
|
4
|
-
## Rationale for changes
|
|
5
|
-
<!--- Explain the necessity of this change -->
|
|
6
|
-
<!--- Include a link to the relevant Jira issue here. -->
|
|
7
|
-
|
|
8
|
-
## Documentation updates
|
|
9
|
-
<!--- Mention any modifications made to the documentation-->
|
|
10
|
-
|
|
11
|
-
## Review and testing instructions
|
|
12
|
-
<!--- Outline the steps the reviewer should follow to test this pull request -->
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
name: npm Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
release:
|
|
8
|
-
types: [published]
|
|
9
|
-
workflow_call:
|
|
10
|
-
inputs:
|
|
11
|
-
version-source:
|
|
12
|
-
description: "Set to 'dunamai' to compute from git, or 'release-tag' to use a provided tag."
|
|
13
|
-
required: true
|
|
14
|
-
type: string
|
|
15
|
-
release-tag:
|
|
16
|
-
description: "Release tag to use when version-source is release-tag."
|
|
17
|
-
required: false
|
|
18
|
-
type: string
|
|
19
|
-
publish-tag:
|
|
20
|
-
description: "npm dist-tag to publish with."
|
|
21
|
-
required: false
|
|
22
|
-
type: string
|
|
23
|
-
default: latest
|
|
24
|
-
|
|
25
|
-
concurrency:
|
|
26
|
-
group: npm-publish-${{ github.ref_name }}-${{ github.event_name }}
|
|
27
|
-
cancel-in-progress: true
|
|
28
|
-
|
|
29
|
-
permissions:
|
|
30
|
-
id-token: write # Required for OIDC
|
|
31
|
-
contents: read
|
|
32
|
-
|
|
33
|
-
jobs:
|
|
34
|
-
npm-publish:
|
|
35
|
-
runs-on: ubuntu-latest
|
|
36
|
-
steps:
|
|
37
|
-
- name: Resolve publish parameters (push)
|
|
38
|
-
if: github.event_name == 'push'
|
|
39
|
-
run: |
|
|
40
|
-
echo "VERSION_SOURCE=dunamai" >> "$GITHUB_ENV"
|
|
41
|
-
echo "PUBLISH_TAG=next" >> "$GITHUB_ENV"
|
|
42
|
-
|
|
43
|
-
- name: Resolve publish parameters (release)
|
|
44
|
-
if: github.event_name == 'release'
|
|
45
|
-
run: |
|
|
46
|
-
echo "VERSION_SOURCE=release-tag" >> "$GITHUB_ENV"
|
|
47
|
-
echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV"
|
|
48
|
-
echo "PUBLISH_TAG=latest" >> "$GITHUB_ENV"
|
|
49
|
-
|
|
50
|
-
- name: Resolve publish parameters (workflow_call)
|
|
51
|
-
if: github.event_name == 'workflow_call'
|
|
52
|
-
run: |
|
|
53
|
-
echo "VERSION_SOURCE=${{ inputs.version-source }}" >> "$GITHUB_ENV"
|
|
54
|
-
echo "RELEASE_TAG=${{ inputs.release-tag }}" >> "$GITHUB_ENV"
|
|
55
|
-
echo "PUBLISH_TAG=${{ inputs.publish-tag }}" >> "$GITHUB_ENV"
|
|
56
|
-
|
|
57
|
-
- uses: actions/checkout@v4
|
|
58
|
-
with:
|
|
59
|
-
persist-credentials: false
|
|
60
|
-
fetch-depth: 0
|
|
61
|
-
|
|
62
|
-
- uses: actions/setup-node@v4
|
|
63
|
-
with:
|
|
64
|
-
node-version: 20.17
|
|
65
|
-
registry-url: https://registry.npmjs.org/
|
|
66
|
-
cache: npm
|
|
67
|
-
|
|
68
|
-
- name: Upgrade npm (trusted publishing requirement) ⬆️
|
|
69
|
-
run: npm install -g npm@^11.5.1
|
|
70
|
-
|
|
71
|
-
- name: Set up Python 🐍
|
|
72
|
-
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_call' && inputs.version-source == 'dunamai') }}
|
|
73
|
-
uses: actions/setup-python@v5
|
|
74
|
-
with:
|
|
75
|
-
python-version: "3.10"
|
|
76
|
-
|
|
77
|
-
- name: Set up Dunamai 🪄
|
|
78
|
-
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_call' && inputs.version-source == 'dunamai') }}
|
|
79
|
-
run: pip install -r requirements-ci.txt
|
|
80
|
-
|
|
81
|
-
- name: Install locked dependencies 🔧
|
|
82
|
-
run: npm ci
|
|
83
|
-
|
|
84
|
-
- name: Version ✅
|
|
85
|
-
run: |
|
|
86
|
-
if [ "${VERSION_SOURCE}" = "dunamai" ]; then
|
|
87
|
-
npm version --no-git-tag-version $(dunamai from git --style semver)
|
|
88
|
-
else
|
|
89
|
-
if [ -z "${RELEASE_TAG}" ]; then
|
|
90
|
-
echo "release-tag input is required when version-source is not 'dunamai'." 1>&2
|
|
91
|
-
exit 1
|
|
92
|
-
fi
|
|
93
|
-
npm version --no-git-tag-version "${RELEASE_TAG}"
|
|
94
|
-
fi
|
|
95
|
-
|
|
96
|
-
- name: Test 🧪
|
|
97
|
-
env:
|
|
98
|
-
TZ: Europe/Helsinki
|
|
99
|
-
run: npm test
|
|
100
|
-
|
|
101
|
-
- name: Publish 📚 (OIDC Trusted Publishing)
|
|
102
|
-
run: npm publish --tag "${PUBLISH_TAG}" --access public --provenance
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
test:
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
|
|
8
|
-
steps:
|
|
9
|
-
- name: Checkout 🛎️
|
|
10
|
-
uses: actions/checkout@v3
|
|
11
|
-
|
|
12
|
-
- name: Install Node.js 💻
|
|
13
|
-
uses: actions/setup-node@v3
|
|
14
|
-
with:
|
|
15
|
-
node-version: 18
|
|
16
|
-
|
|
17
|
-
- name: Install locked dependencies 🔧
|
|
18
|
-
run: npm ci
|
|
19
|
-
|
|
20
|
-
- name: Test 🧪
|
|
21
|
-
env:
|
|
22
|
-
TZ: Europe/Helsinki
|
|
23
|
-
run: npm test
|
package/requirements-ci.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dunamai==1.25.0
|
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
import AccessibilityParser from "../src/accessibility_parser";
|
|
2
|
-
import chai = require("chai");
|
|
3
|
-
import ConformanceParser from "../src/conformance_parser";
|
|
4
|
-
import fs = require("fs");
|
|
5
|
-
import OPDSParser, { OPDSEntry, OPDSFeed } from "../src";
|
|
6
|
-
import PrefixMap from "../src/prefix_map";
|
|
7
|
-
import WaysOfReadingParser from "../src/ways_of_reading_parser";
|
|
8
|
-
|
|
9
|
-
let expect = chai.expect;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// OPDS entry parsing test for accessibility
|
|
13
|
-
|
|
14
|
-
describe("EntryParser, AccessibilityParser, ConformanceParser and WaysOfReadingParser", () => {
|
|
15
|
-
let opdsParser: OPDSParser;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
opdsParser = new OPDSParser();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("#parse", () => {
|
|
22
|
-
|
|
23
|
-
it("extract accessibility attribute from <accessibility>", (done) => {
|
|
24
|
-
fs.readFile("test/files/accessibility.xml", "utf8", (error, data) => {
|
|
25
|
-
if (error) {
|
|
26
|
-
done(error);
|
|
27
|
-
} else {
|
|
28
|
-
let promise: Promise<OPDSFeed | OPDSEntry> = opdsParser.parse(data);
|
|
29
|
-
promise.then((entry: OPDSEntry) => {
|
|
30
|
-
expect(entry.title).to.equals("Accessibility XML test");
|
|
31
|
-
expect(entry.accessibility).to.be.an("object");
|
|
32
|
-
expect(entry.accessibility).to.have.property("waysOfReading");
|
|
33
|
-
expect(entry.accessibility.waysOfReading).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
34
|
-
expect(entry.accessibility.waysOfReading.features).to.include.members([
|
|
35
|
-
"Appearance can be modified",
|
|
36
|
-
"Has alternative text",
|
|
37
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
38
|
-
]);
|
|
39
|
-
expect(entry.accessibility).to.have.property("conformance");
|
|
40
|
-
expect(entry.accessibility.conformance).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
41
|
-
}).then(done, done);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Accessibility parsing tests
|
|
52
|
-
|
|
53
|
-
describe("AccessibilityParser", () => {
|
|
54
|
-
let accessibilityParser: AccessibilityParser;
|
|
55
|
-
|
|
56
|
-
beforeEach(() => {
|
|
57
|
-
let prefixes: PrefixMap = {};
|
|
58
|
-
accessibilityParser = new AccessibilityParser(prefixes);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("#parse", () => {
|
|
62
|
-
|
|
63
|
-
it("extracts conformance attribute", () => {
|
|
64
|
-
|
|
65
|
-
const accessibilityTag = {
|
|
66
|
-
"conformance": [{
|
|
67
|
-
"conformsTo": [
|
|
68
|
-
{"_": "This publication meets accepted accessibility standards"}
|
|
69
|
-
]
|
|
70
|
-
}],
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
74
|
-
|
|
75
|
-
expect(result).to.be.an("object");
|
|
76
|
-
expect(result).to.have.property("conformance");
|
|
77
|
-
expect(result.conformance).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
78
|
-
expect(result).to.have.property("waysOfReading");
|
|
79
|
-
expect(result.waysOfReading).to.be.null;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("extracts ways of reading attribute", () => {
|
|
83
|
-
|
|
84
|
-
const accessibilityTag = {
|
|
85
|
-
"waysOfReading": [{
|
|
86
|
-
"feature": [
|
|
87
|
-
{"_": "Appearance can be modified"},
|
|
88
|
-
{"_": "Has alternative text"},
|
|
89
|
-
{"_": "Not fully readable in read aloud or dynamic braille"}
|
|
90
|
-
]
|
|
91
|
-
}],
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
95
|
-
|
|
96
|
-
expect(result).to.be.an("object");
|
|
97
|
-
expect(result).to.have.property("waysOfReading");
|
|
98
|
-
expect(result.waysOfReading).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
99
|
-
expect(result.waysOfReading.features).to.include.members([
|
|
100
|
-
"Appearance can be modified",
|
|
101
|
-
"Has alternative text",
|
|
102
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
103
|
-
]);
|
|
104
|
-
expect(result).to.have.property("conformance");
|
|
105
|
-
expect(result.conformance).to.be.null;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("extracts conformance and ways of reading attributes", () => {
|
|
109
|
-
|
|
110
|
-
const accessibilityTag = {
|
|
111
|
-
"conformance": [{
|
|
112
|
-
"conformsTo": [
|
|
113
|
-
{"_": "This publication meets accepted accessibility standards"}
|
|
114
|
-
]
|
|
115
|
-
}],
|
|
116
|
-
"waysOfReading": [{
|
|
117
|
-
"feature": [
|
|
118
|
-
{"_": "Appearance can be modified"},
|
|
119
|
-
{"_": "Has alternative text"},
|
|
120
|
-
{"_": "Not fully readable in read aloud or dynamic braille"}
|
|
121
|
-
]
|
|
122
|
-
}]
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
126
|
-
|
|
127
|
-
expect(result).to.be.an("object");
|
|
128
|
-
expect(result).to.have.property("conformance");
|
|
129
|
-
expect(result.conformance).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
130
|
-
expect(result).to.have.property("waysOfReading");
|
|
131
|
-
expect(result.waysOfReading).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
132
|
-
expect(result.waysOfReading.features).to.include.members([
|
|
133
|
-
"Appearance can be modified",
|
|
134
|
-
"Has alternative text",
|
|
135
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
136
|
-
]);
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("extracts only conformance and ways of reading attributes", () => {
|
|
141
|
-
|
|
142
|
-
const accessibilityTag = {
|
|
143
|
-
"conformance": [{
|
|
144
|
-
"conformsTo": [
|
|
145
|
-
{"_": "This publication meets accepted accessibility standards"}
|
|
146
|
-
]
|
|
147
|
-
}],
|
|
148
|
-
"waysOfReading": [{
|
|
149
|
-
"feature": [
|
|
150
|
-
{"_": "Appearance can be modified"},
|
|
151
|
-
{"_": "Has alternative text"},
|
|
152
|
-
{"_": "Not fully readable in read aloud or dynamic braille"}
|
|
153
|
-
]
|
|
154
|
-
}],
|
|
155
|
-
"hazards": [{
|
|
156
|
-
"feature": [
|
|
157
|
-
{"_": "Sounds"},
|
|
158
|
-
{"_": "Motion simulation"},
|
|
159
|
-
{"_": "Flashing content"}
|
|
160
|
-
]
|
|
161
|
-
}]
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
165
|
-
|
|
166
|
-
expect(result).to.be.an("object");
|
|
167
|
-
expect(result).to.have.property("conformance");
|
|
168
|
-
expect(result.conformance).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
169
|
-
expect(result).to.have.property("waysOfReading");
|
|
170
|
-
expect(result.waysOfReading).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
171
|
-
expect(result.waysOfReading.features).to.include.members([
|
|
172
|
-
"Appearance can be modified",
|
|
173
|
-
"Has alternative text",
|
|
174
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
175
|
-
]);
|
|
176
|
-
expect(result).not.to.have.property("hazards");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("extracts conformance and ways of reading attributes if available", () => {
|
|
180
|
-
|
|
181
|
-
const accessibilityTag = {};
|
|
182
|
-
|
|
183
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
184
|
-
|
|
185
|
-
expect(result).to.be.an("object");
|
|
186
|
-
expect(result).to.have.property("conformance");
|
|
187
|
-
expect(result).to.have.property("waysOfReading");
|
|
188
|
-
expect(result.conformance).to.be.null;
|
|
189
|
-
expect(result.waysOfReading).to.be.null;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("extracts only conformance and ways of reading from accessibility if available", () => {
|
|
193
|
-
|
|
194
|
-
const accessibilityTag = {
|
|
195
|
-
"hazards": [{
|
|
196
|
-
"feature": [
|
|
197
|
-
{"_": "Sounds"},
|
|
198
|
-
{"_": "Motion simulation"},
|
|
199
|
-
{"_": "Flashing content"}
|
|
200
|
-
]
|
|
201
|
-
}]
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const result = accessibilityParser.parse(accessibilityTag);
|
|
205
|
-
|
|
206
|
-
expect(result).to.be.an("object");
|
|
207
|
-
expect(Object.keys(result)).to.have.lengthOf(2);
|
|
208
|
-
expect(result).to.have.property("conformance");
|
|
209
|
-
expect(result).to.have.property("waysOfReading");
|
|
210
|
-
expect(result).not.to.have.property("hazards");
|
|
211
|
-
expect(result.conformance).to.be.null;
|
|
212
|
-
expect(result.waysOfReading).to.be.null;
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// Conformance parsing tests
|
|
221
|
-
|
|
222
|
-
describe("ConformanceParser", () => {
|
|
223
|
-
let conformanceParser: ConformanceParser;
|
|
224
|
-
|
|
225
|
-
beforeEach(() => {
|
|
226
|
-
let prefixes: PrefixMap = {};
|
|
227
|
-
conformanceParser = new ConformanceParser(prefixes);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
describe("#parse", () => {
|
|
231
|
-
|
|
232
|
-
it("extracts conformsTo attribute", () => {
|
|
233
|
-
|
|
234
|
-
const conformanceTag = {
|
|
235
|
-
"conformsTo": [
|
|
236
|
-
{
|
|
237
|
-
"_": "This publication meets accepted accessibility standards"
|
|
238
|
-
}
|
|
239
|
-
]
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const result = conformanceParser.parse(conformanceTag);
|
|
243
|
-
|
|
244
|
-
expect(result).to.be.an("object");
|
|
245
|
-
expect(result).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("extracts conformsTo attribute including empty strings", () => {
|
|
249
|
-
|
|
250
|
-
const conformanceTag = {
|
|
251
|
-
"conformsTo": [
|
|
252
|
-
{
|
|
253
|
-
"_": ""
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
const result = conformanceParser.parse(conformanceTag);
|
|
259
|
-
|
|
260
|
-
expect(result).to.be.an("object");
|
|
261
|
-
expect(result).to.have.property("conformsTo", "");
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("extracts only conformsTo attribute", () => {
|
|
265
|
-
|
|
266
|
-
const conformanceTag = {
|
|
267
|
-
"conformsTo": [
|
|
268
|
-
{
|
|
269
|
-
"_": "This publication meets accepted accessibility standards"
|
|
270
|
-
}
|
|
271
|
-
],
|
|
272
|
-
"certifier": [
|
|
273
|
-
{
|
|
274
|
-
"_": "The publication was certified by Certifier"
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const result = conformanceParser.parse(conformanceTag);
|
|
280
|
-
|
|
281
|
-
expect(result).to.be.an("object");
|
|
282
|
-
expect(Object.keys(result)).to.have.lengthOf(1);
|
|
283
|
-
expect(result).to.have.property("conformsTo", "This publication meets accepted accessibility standards");
|
|
284
|
-
expect(result).not.to.have.property("certifier");
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("extracts conformsTo attribute if available", () => {
|
|
288
|
-
|
|
289
|
-
const conformanceTag = {};
|
|
290
|
-
|
|
291
|
-
const result = conformanceParser.parse(conformanceTag);
|
|
292
|
-
|
|
293
|
-
expect(result).to.be.an("object");
|
|
294
|
-
expect(result.conformsTo).to.be.undefined;
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("extracts only conformsTo attribute if available", () => {
|
|
298
|
-
|
|
299
|
-
const conformanceTag = {
|
|
300
|
-
"certifier": [
|
|
301
|
-
{
|
|
302
|
-
"_": "The publication was certified by Certifier"
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const result = conformanceParser.parse(conformanceTag);
|
|
308
|
-
|
|
309
|
-
expect(result).to.be.an("object");
|
|
310
|
-
expect(Object.keys(result)).to.have.lengthOf(1);
|
|
311
|
-
expect(result).to.have.property("conformsTo");
|
|
312
|
-
expect(result.conformsTo).to.be.undefined;
|
|
313
|
-
expect(result).not.to.have.property("certifier");
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
// Ways of reading parsing tests
|
|
321
|
-
|
|
322
|
-
describe("WaysOfReadingParser", () => {
|
|
323
|
-
let waysOfReadingParser: WaysOfReadingParser;
|
|
324
|
-
|
|
325
|
-
beforeEach(() => {
|
|
326
|
-
let prefixes: PrefixMap = {};
|
|
327
|
-
waysOfReadingParser = new WaysOfReadingParser(prefixes);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
describe("#parse", () => {
|
|
331
|
-
|
|
332
|
-
it("extracts waysOfReading attribute", () => {
|
|
333
|
-
|
|
334
|
-
const waysOfReadingTag = {
|
|
335
|
-
"feature": [
|
|
336
|
-
{
|
|
337
|
-
"_": "Appearance can be modified"
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
"_": "Has alternative text"
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
"_": "Not fully readable in read aloud or dynamic braille"
|
|
344
|
-
}
|
|
345
|
-
]
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const result = waysOfReadingParser.parse(waysOfReadingTag);
|
|
349
|
-
|
|
350
|
-
expect(result).to.be.an("object");
|
|
351
|
-
expect(result).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
352
|
-
expect(result.features).to.include.members([
|
|
353
|
-
"Appearance can be modified",
|
|
354
|
-
"Has alternative text",
|
|
355
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
356
|
-
]);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("extracts waysOfReading attribute including empty strings", () => {
|
|
360
|
-
|
|
361
|
-
const waysOfReadingTag = {
|
|
362
|
-
"feature": [
|
|
363
|
-
{
|
|
364
|
-
"_": "Appearance can be modified"
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"_": ""
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
"_": "Not fully readable in read aloud or dynamic braille"
|
|
371
|
-
}
|
|
372
|
-
]
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
const result = waysOfReadingParser.parse(waysOfReadingTag);
|
|
376
|
-
|
|
377
|
-
expect(result).to.be.an("object");
|
|
378
|
-
expect(result).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
379
|
-
expect(result.features).to.include.members([
|
|
380
|
-
"Appearance can be modified",
|
|
381
|
-
"",
|
|
382
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
383
|
-
]);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it("extracts only waysOfReading attribute", () => {
|
|
387
|
-
|
|
388
|
-
const waysOfReadingTag = {
|
|
389
|
-
"feature": [
|
|
390
|
-
{
|
|
391
|
-
"_": "Appearance can be modified"
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
"_": "Has alternative text"
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
"_": "Not fully readable in read aloud or dynamic braille"
|
|
398
|
-
}
|
|
399
|
-
],
|
|
400
|
-
"additionalAccessibilityInformation": [
|
|
401
|
-
{
|
|
402
|
-
"_": "High contrast between foreground text and background"
|
|
403
|
-
}
|
|
404
|
-
]
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
const result = waysOfReadingParser.parse(waysOfReadingTag);
|
|
408
|
-
|
|
409
|
-
expect(result).to.be.an("object");
|
|
410
|
-
expect(Object.keys(result)).to.have.lengthOf(1);
|
|
411
|
-
expect(result).to.have.property("features").that.is.an("array").that.has.lengthOf(3);
|
|
412
|
-
expect(result.features).to.include.members([
|
|
413
|
-
"Appearance can be modified",
|
|
414
|
-
"Has alternative text",
|
|
415
|
-
"Not fully readable in read aloud or dynamic braille"
|
|
416
|
-
]);
|
|
417
|
-
expect(result).not.to.have.property("additionalAccessibilityInformation");
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it("extracts waysOfReading attribute if available", () => {
|
|
421
|
-
|
|
422
|
-
const waysOfReadingTag = {};
|
|
423
|
-
|
|
424
|
-
const result = waysOfReadingParser.parse(waysOfReadingTag);
|
|
425
|
-
|
|
426
|
-
expect(result).to.be.an("object");
|
|
427
|
-
expect(result).to.have.property("features").that.is.an("array").that.has.lengthOf(0);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it("extracts only waysOfReading attribute if available", () => {
|
|
431
|
-
|
|
432
|
-
const waysOfReadingTag = {
|
|
433
|
-
"additionalAccessibilityInformation": [
|
|
434
|
-
{
|
|
435
|
-
"_": "High contrast between foreground text and background"
|
|
436
|
-
}
|
|
437
|
-
]
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const result = waysOfReadingParser.parse(waysOfReadingTag);
|
|
441
|
-
|
|
442
|
-
expect(result).to.be.an("object");
|
|
443
|
-
expect(Object.keys(result)).to.have.lengthOf(1);
|
|
444
|
-
expect(result).to.have.property("features").that.is.an("array").that.has.lengthOf(0);
|
|
445
|
-
expect(result).not.to.have.property("additionalAccessibilityInformation");
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import PrefixMap from "../src/prefix_map";
|
|
2
|
-
import OPDSAvailability from "../src/opds_availability";
|
|
3
|
-
import AvailabilityParser from "../src/availability_parser";
|
|
4
|
-
import NamespaceParser from "../src/namespace_parser";
|
|
5
|
-
import chai = require("chai");
|
|
6
|
-
let expect = chai.expect;
|
|
7
|
-
|
|
8
|
-
describe("AvailabilityParser", () => {
|
|
9
|
-
let parser: AvailabilityParser;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
let prefixes: PrefixMap = {};
|
|
13
|
-
prefixes[NamespaceParser.OPDS_URI] = "opds:";
|
|
14
|
-
parser = new AvailabilityParser(prefixes);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("#parse", () => {
|
|
18
|
-
it("extract attributes", () => {
|
|
19
|
-
let availability = {
|
|
20
|
-
$: {
|
|
21
|
-
status: { value: "reserved" },
|
|
22
|
-
since: { value: "2016-07-26T15:46:19Z" },
|
|
23
|
-
until: { value: "2016-11-02T19:46:27Z" }
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
let parsed = parser.parse(availability);
|
|
27
|
-
expect(parsed.status).to.equals("reserved");
|
|
28
|
-
expect(parsed.since).to.equals("2016-07-26T15:46:19Z");
|
|
29
|
-
expect(parsed.until).to.equals("2016-11-02T19:46:27Z");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|