@internetarchive/bookreader 5.0.0-43 → 5.0.0-44-a3
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/BookReader/BookReader.css +1 -2
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +36 -36
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReaderDemo/IADemoBr.js +22 -0
- package/BookReaderDemo/demo-internetarchive.html +3 -0
- package/babel.config.js +1 -1
- package/package.json +15 -21
- package/renovate.json +7 -4
- package/src/BookNavigator/book-navigator.js +4 -0
- package/src/BookNavigator/downloads/downloads-provider.js +14 -5
- package/src/BookNavigator/downloads/downloads.js +25 -1
- package/src/BookNavigator/search/search-provider.js +1 -0
- package/src/BookNavigator/search/search-results.js +4 -0
- package/src/css/_controls.scss +1 -2
- package/src/plugins/search/plugin.search.js +8 -0
- package/src/plugins/tts/plugin.tts.js +15 -3
- package/tests/{karma → jest}/BookNavigator/book-navigator.test.js +119 -104
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-button.test.js +13 -14
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/{karma → jest}/BookNavigator/downloads/downloads-provider.test.js +18 -18
- package/tests/{karma → jest}/BookNavigator/downloads/downloads.test.js +7 -8
- package/tests/{karma → jest}/BookNavigator/sharing/sharing-provider.test.js +8 -8
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/{karma → jest}/BookNavigator/volumes/volumes-provider.test.js +38 -38
- package/tests/{karma → jest}/BookNavigator/volumes/volumes.test.js +15 -16
- package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +3 -3
- package/karma.conf.js +0 -23
- package/tests/karma/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -57
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
@@ -0,0 +1,200 @@
|
|
1
|
+
import {
|
2
|
+
html,
|
3
|
+
fixture,
|
4
|
+
oneEvent,
|
5
|
+
} from '@open-wc/testing-helpers';
|
6
|
+
import sinon from 'sinon';
|
7
|
+
import { IABookVisualAdjustments } from '@/src/BookNavigator/visual-adjustments/visual-adjustments.js';
|
8
|
+
|
9
|
+
const options = [{
|
10
|
+
id: 'contrast',
|
11
|
+
name: 'Adjust contrast',
|
12
|
+
active: true,
|
13
|
+
min: 0,
|
14
|
+
max: 150,
|
15
|
+
step: 1,
|
16
|
+
value: 100,
|
17
|
+
}, {
|
18
|
+
id: 'invert',
|
19
|
+
name: 'Invert colors',
|
20
|
+
active: false,
|
21
|
+
}, {
|
22
|
+
id: 'brightness',
|
23
|
+
name: 'Adjust brightness',
|
24
|
+
active: false,
|
25
|
+
value: 100,
|
26
|
+
}];
|
27
|
+
|
28
|
+
const container = (renderHeader = false) => (
|
29
|
+
html`<ia-book-visual-adjustments .options=${options} ?renderHeader=${renderHeader}></ia-book-visual-adjustments>`
|
30
|
+
);
|
31
|
+
|
32
|
+
describe('<ia-book-visual-adjustments>', () => {
|
33
|
+
afterEach(() => {
|
34
|
+
sinon.restore();
|
35
|
+
});
|
36
|
+
|
37
|
+
test('sets default properties', async () => {
|
38
|
+
const el = await fixture(container());
|
39
|
+
|
40
|
+
expect(el.options).toBeDefined();
|
41
|
+
expect(el.options.length).toEqual(options.length);
|
42
|
+
expect(el.renderHeader).toBeDefined();
|
43
|
+
expect(el.renderHeader).toBeFalsy();
|
44
|
+
expect(el.activeCount).toBeDefined();
|
45
|
+
expect(el.showZoomControls).toBeTruthy();
|
46
|
+
});
|
47
|
+
|
48
|
+
test('renders all properties of a visual adjustment option', async () => {
|
49
|
+
const el = await fixture(container());
|
50
|
+
|
51
|
+
await el.updateComplete;
|
52
|
+
|
53
|
+
const label = el.shadowRoot.querySelector('label');
|
54
|
+
const name = label.querySelector('.name');
|
55
|
+
const checkbox = label.querySelector('input');
|
56
|
+
expect(name.textContent).toEqual(options[0].name);
|
57
|
+
expect(checkbox.checked).toEqual(true);
|
58
|
+
});
|
59
|
+
|
60
|
+
test('can render header with active options count', async () => {
|
61
|
+
const renderHeader = true;
|
62
|
+
const el = await fixture(container(renderHeader));
|
63
|
+
expect(el.shadowRoot.querySelector('header p').textContent).toContain('1');
|
64
|
+
});
|
65
|
+
|
66
|
+
test('does not render active options count element when none are selected', async () => {
|
67
|
+
const el = await fixture(container());
|
68
|
+
|
69
|
+
el.options = [options[1]];
|
70
|
+
await el.updateComplete;
|
71
|
+
|
72
|
+
expect(el.shadowRoot.querySelector('header p')).toBe(null);
|
73
|
+
});
|
74
|
+
|
75
|
+
test('changes option\'s active state when input changed', async () => {
|
76
|
+
const el = await fixture(container());
|
77
|
+
|
78
|
+
el.shadowRoot.querySelector('li input').dispatchEvent(new Event('change'));
|
79
|
+
await el.updateComplete;
|
80
|
+
|
81
|
+
expect(el.options[0].active).toEqual(false);
|
82
|
+
});
|
83
|
+
|
84
|
+
test('renders zoom in and out controls when enabled', async () => {
|
85
|
+
const el = await fixture(container());
|
86
|
+
|
87
|
+
expect(el.shadowRoot.querySelector('.zoom_out')).toBeDefined();
|
88
|
+
expect(el.shadowRoot.querySelector('.zoom_in')).toBeDefined();
|
89
|
+
});
|
90
|
+
|
91
|
+
test('does not render zoom controls when disabled', async () => {
|
92
|
+
const el = await fixture(container());
|
93
|
+
|
94
|
+
el.showZoomControls = false;
|
95
|
+
await el.updateComplete;
|
96
|
+
|
97
|
+
expect(el.shadowRoot.querySelector('.zoom_out')).toBe(null);
|
98
|
+
expect(el.shadowRoot.querySelector('.zoom_in')).toBe(null);
|
99
|
+
});
|
100
|
+
|
101
|
+
describe('Custom events', () => {
|
102
|
+
test('prepareEventDetails returns proper params', async () => {
|
103
|
+
const el = await fixture(container());
|
104
|
+
await el.updateComplete;
|
105
|
+
const params = el.prepareEventDetails();
|
106
|
+
|
107
|
+
expect(params.activeCount).toBeDefined();
|
108
|
+
expect(typeof (params.activeCount)).toEqual('number');
|
109
|
+
expect(params.changedOptionId).toBeDefined();
|
110
|
+
expect(typeof (params.changedOptionId)).toEqual('string');
|
111
|
+
expect(params.options).toBeDefined();
|
112
|
+
expect(params.options.length).toBeDefined();
|
113
|
+
expect(params.options.length).toBeGreaterThan(0);
|
114
|
+
});
|
115
|
+
test('emitOptionChangedEvent calls for the params', async () => {
|
116
|
+
IABookVisualAdjustments.prototype.prepareEventDetails = sinon.fake();
|
117
|
+
const el = await fixture(container());
|
118
|
+
await el.updateComplete;
|
119
|
+
|
120
|
+
expect(el.prepareEventDetails.callCount).toEqual(1);
|
121
|
+
});
|
122
|
+
test('triggers an emitOptionChangedEvent event at firstUpdate', async () => {
|
123
|
+
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
124
|
+
const el = await fixture(container());
|
125
|
+
|
126
|
+
expect(el.emitOptionChangedEvent.callCount).toEqual(1);
|
127
|
+
});
|
128
|
+
|
129
|
+
test('triggers an emitOptionChangedEvent event when a checkbox\'s change event fires', async () => {
|
130
|
+
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
131
|
+
const el = await fixture(container());
|
132
|
+
|
133
|
+
expect(el.emitOptionChangedEvent.callCount).toEqual(1); // firstUpdate fire
|
134
|
+
|
135
|
+
el.shadowRoot.querySelector('li input').dispatchEvent(new Event('change'));
|
136
|
+
expect(el.emitOptionChangedEvent.callCount).toEqual(2);
|
137
|
+
});
|
138
|
+
|
139
|
+
test('triggers an emitOptionChangedEvent event when a range\'s change event fires', async () => {
|
140
|
+
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
141
|
+
|
142
|
+
const el = await fixture(container());
|
143
|
+
expect(el.emitOptionChangedEvent.callCount).toEqual(1); // firstUpdate fire
|
144
|
+
|
145
|
+
el.shadowRoot.querySelector('[name="brightness_range"]').dispatchEvent(new Event('change'));
|
146
|
+
expect(el.emitOptionChangedEvent.callCount).toEqual(2);
|
147
|
+
});
|
148
|
+
|
149
|
+
test('emits a zoom out event when zoom out button clicked', async () => {
|
150
|
+
const el = await fixture(container());
|
151
|
+
|
152
|
+
setTimeout(() => (
|
153
|
+
el.shadowRoot.querySelector('.zoom_out').click()
|
154
|
+
));
|
155
|
+
const response = await oneEvent(el, 'visualAdjustmentZoomOut');
|
156
|
+
|
157
|
+
expect(response).toBeDefined();
|
158
|
+
});
|
159
|
+
|
160
|
+
test('emits a zoom in event when zoom in button clicked', async () => {
|
161
|
+
const el = await fixture(container());
|
162
|
+
|
163
|
+
setTimeout(() => (
|
164
|
+
el.shadowRoot.querySelector('.zoom_in').click()
|
165
|
+
));
|
166
|
+
const response = await oneEvent(el, 'visualAdjustmentZoomIn');
|
167
|
+
|
168
|
+
expect(response).toBeDefined();
|
169
|
+
});
|
170
|
+
});
|
171
|
+
|
172
|
+
test('sets range defaults when none supplied', async () => {
|
173
|
+
const el = await fixture(container());
|
174
|
+
const brightnessRange = el.shadowRoot.querySelector('[name="brightness_range"]');
|
175
|
+
|
176
|
+
expect(brightnessRange.getAttribute('min')).toEqual('0');
|
177
|
+
expect(brightnessRange.getAttribute('max')).toEqual('100');
|
178
|
+
expect(brightnessRange.getAttribute('step')).toEqual('1');
|
179
|
+
});
|
180
|
+
|
181
|
+
test('sets the updated range value on the options prop', async () => {
|
182
|
+
const el = await fixture(container());
|
183
|
+
const { id } = options[0];
|
184
|
+
const newValue = 120;
|
185
|
+
|
186
|
+
el.setRangeValue(id, newValue);
|
187
|
+
await el.updateComplete;
|
188
|
+
|
189
|
+
expect(el.options[0].value).toEqual(newValue);
|
190
|
+
});
|
191
|
+
|
192
|
+
test('triggers a setRangeValue event when a range\'s input event fires', async () => {
|
193
|
+
IABookVisualAdjustments.prototype.setRangeValue = sinon.fake();
|
194
|
+
|
195
|
+
const el = await fixture(container());
|
196
|
+
|
197
|
+
el.shadowRoot.querySelector('[name="brightness_range"]').dispatchEvent(new Event('input'));
|
198
|
+
expect(el.setRangeValue.callCount).toEqual(1);
|
199
|
+
});
|
200
|
+
});
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { fixture, fixtureCleanup, fixtureSync } from '@open-wc/testing-helpers';
|
2
2
|
import sinon from 'sinon';
|
3
|
-
import volumesProvider from '
|
3
|
+
import volumesProvider from '@/src/BookNavigator/volumes/volumes-provider';
|
4
4
|
|
5
5
|
const brOptions = {
|
6
6
|
"options": {
|
@@ -39,7 +39,7 @@ afterEach(() => {
|
|
39
39
|
});
|
40
40
|
|
41
41
|
describe('Volumes Provider', () => {
|
42
|
-
|
42
|
+
test('constructor', () => {
|
43
43
|
const onProviderChange = sinon.fake();
|
44
44
|
const baseHost = "https://archive.org";
|
45
45
|
const provider = new volumesProvider({
|
@@ -51,20 +51,20 @@ describe('Volumes Provider', () => {
|
|
51
51
|
const files = brOptions.options.multipleBooksList.by_subprefix;
|
52
52
|
const volumeCount = Object.keys(files).length;
|
53
53
|
|
54
|
-
expect(provider.onProviderChange).
|
55
|
-
expect(provider.id).
|
56
|
-
expect(provider.icon).
|
57
|
-
expect(fixtureSync(provider.icon).tagName).
|
58
|
-
expect(provider.label).
|
59
|
-
expect(provider.viewableFiles).
|
60
|
-
expect(provider.viewableFiles.length).
|
61
|
-
|
62
|
-
expect(provider.component.hostUrl).
|
63
|
-
expect(provider.component.hostUrl).
|
64
|
-
expect(provider.component).
|
54
|
+
expect(provider.onProviderChange).toEqual(onProviderChange);
|
55
|
+
expect(provider.id).toEqual('volumes');
|
56
|
+
expect(provider.icon).toBeDefined();
|
57
|
+
expect(fixtureSync(provider.icon).tagName).toEqual('svg');
|
58
|
+
expect(provider.label).toEqual(`Viewable files (${volumeCount})`);
|
59
|
+
expect(provider.viewableFiles).toBeDefined();
|
60
|
+
expect(provider.viewableFiles.length).toEqual(3);
|
61
|
+
|
62
|
+
expect(provider.component.hostUrl).toBeDefined();
|
63
|
+
expect(provider.component.hostUrl).toEqual(baseHost);
|
64
|
+
expect(provider.component).toBeDefined();
|
65
65
|
});
|
66
66
|
|
67
|
-
|
67
|
+
test('sorting cycles - render sort actionButton', async () => {
|
68
68
|
const onProviderChange = sinon.fake();
|
69
69
|
const baseHost = "https://archive.org";
|
70
70
|
const provider = new volumesProvider({
|
@@ -73,22 +73,22 @@ describe('Volumes Provider', () => {
|
|
73
73
|
onProviderChange
|
74
74
|
});
|
75
75
|
|
76
|
-
expect(provider.sortOrderBy).
|
76
|
+
expect(provider.sortOrderBy).toEqual("default");
|
77
77
|
|
78
78
|
provider.sortVolumes("title_asc");
|
79
|
-
expect(provider.sortOrderBy).
|
80
|
-
expect(fixtureSync(provider.sortButton).outerHTML).
|
79
|
+
expect(provider.sortOrderBy).toEqual("title_asc");
|
80
|
+
expect(fixtureSync(provider.sortButton).outerHTML).toContain("sort-by asc-icon");
|
81
81
|
|
82
82
|
provider.sortVolumes("title_desc");
|
83
|
-
expect(provider.sortOrderBy).
|
84
|
-
expect(fixtureSync(provider.sortButton).outerHTML).
|
83
|
+
expect(provider.sortOrderBy).toEqual("title_desc");
|
84
|
+
expect(fixtureSync(provider.sortButton).outerHTML).toContain("sort-by desc-icon");
|
85
85
|
|
86
86
|
provider.sortVolumes("default");
|
87
|
-
expect(provider.sortOrderBy).
|
88
|
-
expect(fixtureSync(provider.sortButton).outerHTML).
|
87
|
+
expect(provider.sortOrderBy).toEqual("default");
|
88
|
+
expect(fixtureSync(provider.sortButton).outerHTML).toContain("sort-by neutral-icon");
|
89
89
|
});
|
90
90
|
|
91
|
-
|
91
|
+
test('sort volumes in initial order', async () => {
|
92
92
|
const onProviderChange = sinon.fake();
|
93
93
|
const baseHost = "https://archive.org";
|
94
94
|
const provider = new volumesProvider({
|
@@ -103,15 +103,15 @@ describe('Volumes Provider', () => {
|
|
103
103
|
|
104
104
|
provider.sortVolumes("default");
|
105
105
|
|
106
|
-
expect(provider.sortOrderBy).
|
107
|
-
expect(provider.actionButton).
|
106
|
+
expect(provider.sortOrderBy).toEqual("default");
|
107
|
+
expect(provider.actionButton).toBeDefined();
|
108
108
|
|
109
109
|
const providerFileTitles = provider.viewableFiles.map(item => item.title);
|
110
110
|
// use `.eql` for "lose equality" in order to deeply compare values.
|
111
|
-
expect(providerFileTitles).
|
111
|
+
expect(providerFileTitles).toEqual([...origSortTitles]);
|
112
112
|
});
|
113
113
|
|
114
|
-
|
114
|
+
test('sort volumes in ascending title order', async () => {
|
115
115
|
const onProviderChange = sinon.fake();
|
116
116
|
const baseHost = "https://archive.org";
|
117
117
|
const provider = new volumesProvider({
|
@@ -126,15 +126,15 @@ describe('Volumes Provider', () => {
|
|
126
126
|
|
127
127
|
provider.sortVolumes("title_asc");
|
128
128
|
|
129
|
-
expect(provider.sortOrderBy).
|
130
|
-
expect(provider.actionButton).
|
129
|
+
expect(provider.sortOrderBy).toEqual("title_asc");
|
130
|
+
expect(provider.actionButton).toBeDefined();
|
131
131
|
|
132
132
|
const providerFileTitles = provider.viewableFiles.map(item => item.title);
|
133
133
|
// use `.eql` for "lose equality" in order to deeply compare values.
|
134
|
-
expect(providerFileTitles).
|
134
|
+
expect(providerFileTitles).toEqual([...ascendingTitles]);
|
135
135
|
});
|
136
136
|
|
137
|
-
|
137
|
+
test('sort volumes in descending title order', async () => {
|
138
138
|
const onProviderChange = sinon.fake();
|
139
139
|
const baseHost = "https://archive.org";
|
140
140
|
const provider = new volumesProvider({
|
@@ -150,16 +150,16 @@ describe('Volumes Provider', () => {
|
|
150
150
|
|
151
151
|
provider.sortVolumes("title_desc");
|
152
152
|
|
153
|
-
expect(provider.sortOrderBy).
|
154
|
-
expect(provider.actionButton).
|
153
|
+
expect(provider.sortOrderBy).toEqual("title_desc");
|
154
|
+
expect(provider.actionButton).toBeDefined();
|
155
155
|
|
156
156
|
const providerFileTitles = provider.viewableFiles.map(item => item.title);
|
157
157
|
// use `.eql` for "lose equality" in order to deeply compare values.
|
158
|
-
expect(providerFileTitles).
|
158
|
+
expect(providerFileTitles).toEqual([...descendingTitles]);
|
159
159
|
});
|
160
160
|
|
161
161
|
describe('Sorting icons', () => {
|
162
|
-
|
162
|
+
test('has 3 icons', async () => {
|
163
163
|
const onProviderChange = sinon.fake();
|
164
164
|
const baseHost = "https://archive.org";
|
165
165
|
const provider = new volumesProvider({
|
@@ -170,15 +170,15 @@ describe('Volumes Provider', () => {
|
|
170
170
|
provider.sortOrderBy = 'default';
|
171
171
|
|
172
172
|
const origSortButton = await fixture(provider.sortButton);
|
173
|
-
expect(origSortButton.classList.contains('neutral-icon')).
|
173
|
+
expect(origSortButton.classList.contains('neutral-icon')).toBeTruthy();
|
174
174
|
|
175
175
|
provider.sortOrderBy = 'title_asc';
|
176
176
|
const ascButton = await fixture(provider.sortButton);
|
177
|
-
expect(ascButton.classList.contains('asc-icon')).
|
177
|
+
expect(ascButton.classList.contains('asc-icon')).toBeTruthy();
|
178
178
|
|
179
179
|
provider.sortOrderBy = 'title_desc';
|
180
180
|
const descButton = await fixture(provider.sortButton);
|
181
|
-
expect(descButton.classList.contains('desc-icon')).
|
181
|
+
expect(descButton.classList.contains('desc-icon')).toBeTruthy();
|
182
182
|
});
|
183
183
|
});
|
184
184
|
});
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import {
|
2
2
|
html,
|
3
3
|
fixture,
|
4
|
-
expect,
|
5
4
|
fixtureCleanup,
|
6
|
-
} from '@open-wc/testing';
|
5
|
+
} from '@open-wc/testing-helpers';
|
7
6
|
import sinon from 'sinon';
|
8
|
-
import '
|
7
|
+
import '@/src/BookNavigator/volumes/volumes.js';
|
9
8
|
|
10
9
|
|
11
10
|
const brOptions = {
|
@@ -58,30 +57,30 @@ afterEach(() => {
|
|
58
57
|
});
|
59
58
|
|
60
59
|
describe('<viewable-files>', () => {
|
61
|
-
|
60
|
+
test('sets default properties', async () => {
|
62
61
|
const files = brOptions.options.multipleBooksList?.by_subprefix;
|
63
62
|
const viewableFiles = Object.keys(files).map(item => files[item]);
|
64
63
|
const el = await fixture(container(viewableFiles));
|
65
64
|
await el.updateComplete;
|
66
65
|
|
67
|
-
expect(el.viewableFiles).
|
68
|
-
expect(el.viewableFiles.length).
|
69
|
-
expect(el.shadowRoot.querySelectorAll("ul li").length).
|
66
|
+
expect(el.viewableFiles).toEqual(viewableFiles);
|
67
|
+
expect(el.viewableFiles.length).toEqual(3);
|
68
|
+
expect(el.shadowRoot.querySelectorAll("ul li").length).toEqual(3);
|
70
69
|
|
71
|
-
expect(el.shadowRoot.querySelector(".item-title").
|
70
|
+
expect(el.shadowRoot.querySelector(".item-title").textContent).toContain(`${viewableFiles[0].title}`);
|
72
71
|
});
|
73
72
|
|
74
|
-
|
73
|
+
test('render empty volumes', async () => {
|
75
74
|
const viewableFiles = [];
|
76
75
|
const el = await fixture(container(viewableFiles));
|
77
76
|
await el.updateComplete;
|
78
77
|
|
79
|
-
expect(el.viewableFiles).
|
80
|
-
expect(el.viewableFiles.length).
|
81
|
-
expect(el.shadowRoot.childElementCount).
|
78
|
+
expect(el.viewableFiles).toEqual(viewableFiles);
|
79
|
+
expect(el.viewableFiles.length).toEqual(0);
|
80
|
+
expect(el.shadowRoot.childElementCount).not.toEqual(0);
|
82
81
|
});
|
83
82
|
|
84
|
-
|
83
|
+
test('render active volume item set as first viewable item ', async () => {
|
85
84
|
const files = brOptions.options.multipleBooksList?.by_subprefix;
|
86
85
|
const viewableFiles = Object.keys(files).map(item => files[item]);
|
87
86
|
const prefix = viewableFiles[0].file_subprefix;
|
@@ -89,10 +88,10 @@ describe('<viewable-files>', () => {
|
|
89
88
|
const el = await fixture(container(viewableFiles, prefix));
|
90
89
|
await el.updateComplete;
|
91
90
|
|
92
|
-
expect(el.viewableFiles).
|
93
|
-
expect(el.viewableFiles.length).
|
91
|
+
expect(el.viewableFiles).toEqual(viewableFiles);
|
92
|
+
expect(el.viewableFiles.length).toEqual(3);
|
94
93
|
|
95
|
-
expect(el.shadowRoot.querySelectorAll("ul li div")[1].className).
|
94
|
+
expect(el.shadowRoot.querySelectorAll("ul li div")[1].className).toEqual("content active");
|
96
95
|
});
|
97
96
|
|
98
97
|
});
|
@@ -20,7 +20,7 @@ describe.skip('AbstractTTSEngine', () => {
|
|
20
20
|
});
|
21
21
|
});
|
22
22
|
|
23
|
-
for (const dummyVoice of [
|
23
|
+
for (const dummyVoice of [dummyVoiceHyphens, dummyVoiceUnderscores]) {
|
24
24
|
describe(`getBestBookVoice with BCP47 ${dummyVoice == dummyVoiceUnderscores ? '+' : '-'} underscores`, () => {
|
25
25
|
const { getBestBookVoice } = AbstractTTSEngine;
|
26
26
|
|
@@ -130,7 +130,7 @@ export const DUMMY_TTS_ENGINE_OPTS = {
|
|
130
130
|
* @param {SpeechSynthesisVoice}
|
131
131
|
* @return {SpeechSynthesisVoice}
|
132
132
|
**/
|
133
|
-
function
|
133
|
+
function dummyVoiceHyphens(overrides) {
|
134
134
|
return Object.assign({
|
135
135
|
default: false,
|
136
136
|
lang: "en-US",
|
@@ -147,7 +147,7 @@ function dummyVoice(overrides) {
|
|
147
147
|
* @return {SpeechSynthesisVoice}
|
148
148
|
**/
|
149
149
|
function dummyVoiceUnderscores(overrides) {
|
150
|
-
const voice =
|
150
|
+
const voice = dummyVoiceHyphens(overrides);
|
151
151
|
voice.lang = voice.lang.replace('-', '_');
|
152
152
|
return voice;
|
153
153
|
}
|
package/karma.conf.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
const { createDefaultConfig } = require('@open-wc/testing-karma');
|
2
|
-
const merge = require('deepmerge');
|
3
|
-
|
4
|
-
module.exports = (config) => {
|
5
|
-
config.set(
|
6
|
-
merge(createDefaultConfig(config), {
|
7
|
-
files: [
|
8
|
-
// runs all files ending with .test in the test folder,
|
9
|
-
// can be overwritten by passing a --grep flag. examples:
|
10
|
-
//
|
11
|
-
// npm run test -- --grep test/foo/bar.test.js
|
12
|
-
// npm run test -- --grep test/bar/*
|
13
|
-
{ pattern: config.grep ? config.grep : 'tests/karma/**/*.test.js', type: 'module' },
|
14
|
-
],
|
15
|
-
|
16
|
-
esm: {
|
17
|
-
nodeResolve: true,
|
18
|
-
},
|
19
|
-
// you can overwrite/extend the config further
|
20
|
-
}),
|
21
|
-
);
|
22
|
-
return config;
|
23
|
-
};
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
html,
|
3
|
-
fixtureSync,
|
4
|
-
expect,
|
5
|
-
fixtureCleanup,
|
6
|
-
} from '@open-wc/testing';
|
7
|
-
import '../../../../src/BookNavigator/bookmarks/ia-bookmarks.js';
|
8
|
-
import sinon from 'sinon';
|
9
|
-
|
10
|
-
afterEach(() => {
|
11
|
-
sinon.restore();
|
12
|
-
fixtureCleanup();
|
13
|
-
});
|
14
|
-
|
15
|
-
describe('<ia-bookmarks>', () => {
|
16
|
-
it('uses `setup` to start component', async () => {
|
17
|
-
const el = fixtureSync(html`<ia-bookmarks></ia-bookmarks>`);
|
18
|
-
await el.updateComplete;
|
19
|
-
|
20
|
-
let fetchHappened = false;
|
21
|
-
el.bookreader.bookId = 'foo';
|
22
|
-
el.displayMode = 'bookmarks';
|
23
|
-
|
24
|
-
el.fetchBookmarks = async () => {
|
25
|
-
fetchHappened = true;
|
26
|
-
return await Promise.resolve();
|
27
|
-
};
|
28
|
-
|
29
|
-
const fetchSpy = sinon.spy(el, 'fetchUserBookmarks');
|
30
|
-
|
31
|
-
el.setup();
|
32
|
-
await el.updateComplete;
|
33
|
-
|
34
|
-
expect(fetchSpy.callCount).to.equal(1);
|
35
|
-
expect(fetchHappened).to.equal(true);
|
36
|
-
});
|
37
|
-
it('does not fetch user bookmarks if displayMode = login', async () => {
|
38
|
-
const el = fixtureSync(html`<ia-bookmarks></ia-bookmarks>`);
|
39
|
-
await el.updateComplete;
|
40
|
-
|
41
|
-
let fetchHappened = false;
|
42
|
-
el.displayMode = 'login';
|
43
|
-
|
44
|
-
el.fetchBookmarks = async () => {
|
45
|
-
fetchHappened = true;
|
46
|
-
return await Promise.resolve();
|
47
|
-
};
|
48
|
-
|
49
|
-
const fetchSpy = sinon.spy(el, 'fetchUserBookmarks');
|
50
|
-
|
51
|
-
el.setup();
|
52
|
-
await el.updateComplete;
|
53
|
-
|
54
|
-
expect(fetchSpy.callCount).to.equal(0);
|
55
|
-
expect(fetchHappened).to.equal(false);
|
56
|
-
});
|
57
|
-
});
|