@internetarchive/bookreader 5.0.0-43 → 5.0.0-44-a1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +35 -35
- package/BookReader/ia-bookreader-bundle.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 +30 -0
- package/BookReaderDemo/demo-internetarchive.html +3 -0
- package/babel.config.js +1 -1
- package/package.json +10 -16
- 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 +23 -1
- package/src/css/_controls.scss +1 -2
- 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
@@ -1,201 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
html,
|
3
|
-
fixture,
|
4
|
-
expect,
|
5
|
-
oneEvent,
|
6
|
-
} from '@open-wc/testing';
|
7
|
-
import sinon from 'sinon';
|
8
|
-
import { IABookVisualAdjustments } from '../../../src/BookNavigator/visual-adjustments/visual-adjustments.js';
|
9
|
-
|
10
|
-
const options = [{
|
11
|
-
id: 'contrast',
|
12
|
-
name: 'Adjust contrast',
|
13
|
-
active: true,
|
14
|
-
min: 0,
|
15
|
-
max: 150,
|
16
|
-
step: 1,
|
17
|
-
value: 100,
|
18
|
-
}, {
|
19
|
-
id: 'invert',
|
20
|
-
name: 'Invert colors',
|
21
|
-
active: false,
|
22
|
-
}, {
|
23
|
-
id: 'brightness',
|
24
|
-
name: 'Adjust brightness',
|
25
|
-
active: false,
|
26
|
-
value: 100,
|
27
|
-
}];
|
28
|
-
|
29
|
-
const container = (renderHeader = false) => (
|
30
|
-
html`<ia-book-visual-adjustments .options=${options} ?renderHeader=${renderHeader}></ia-book-visual-adjustments>`
|
31
|
-
);
|
32
|
-
|
33
|
-
describe('<ia-book-visual-adjustments>', () => {
|
34
|
-
afterEach(() => {
|
35
|
-
sinon.restore();
|
36
|
-
});
|
37
|
-
|
38
|
-
it('sets default properties', async () => {
|
39
|
-
const el = await fixture(container());
|
40
|
-
|
41
|
-
expect(el.options).to.exist;
|
42
|
-
expect(el.options.length).to.equal(options.length);
|
43
|
-
expect(el.renderHeader).to.exist;
|
44
|
-
expect(el.renderHeader).to.be.false;
|
45
|
-
expect(el.activeCount).to.exist;
|
46
|
-
expect(el.showZoomControls).to.be.true;
|
47
|
-
});
|
48
|
-
|
49
|
-
it('renders all properties of a visual adjustment option', async () => {
|
50
|
-
const el = await fixture(container());
|
51
|
-
|
52
|
-
await el.updateComplete;
|
53
|
-
|
54
|
-
const label = el.shadowRoot.querySelector('label');
|
55
|
-
const name = label.querySelector('.name');
|
56
|
-
const checkbox = label.querySelector('input');
|
57
|
-
expect(name.innerText).to.equal(options[0].name);
|
58
|
-
expect(checkbox.checked).to.equal(true);
|
59
|
-
});
|
60
|
-
|
61
|
-
it('can render header with active options count', async () => {
|
62
|
-
const renderHeader = true;
|
63
|
-
const el = await fixture(container(renderHeader));
|
64
|
-
expect(el.shadowRoot.querySelector('header p').innerText).to.include('1');
|
65
|
-
});
|
66
|
-
|
67
|
-
it('does not render active options count element when none are selected', async () => {
|
68
|
-
const el = await fixture(container());
|
69
|
-
|
70
|
-
el.options = [options[1]];
|
71
|
-
await el.updateComplete;
|
72
|
-
|
73
|
-
expect(el.shadowRoot.querySelector('header p')).not.to.exist;
|
74
|
-
});
|
75
|
-
|
76
|
-
it('changes option\'s active state when input changed', async () => {
|
77
|
-
const el = await fixture(container());
|
78
|
-
|
79
|
-
el.shadowRoot.querySelector('li input').dispatchEvent(new Event('change'));
|
80
|
-
await el.updateComplete;
|
81
|
-
|
82
|
-
expect(el.options[0].active).to.equal(false);
|
83
|
-
});
|
84
|
-
|
85
|
-
it('renders zoom in and out controls when enabled', async () => {
|
86
|
-
const el = await fixture(container());
|
87
|
-
|
88
|
-
expect(el.shadowRoot.querySelector('.zoom_out')).to.exist;
|
89
|
-
expect(el.shadowRoot.querySelector('.zoom_in')).to.exist;
|
90
|
-
});
|
91
|
-
|
92
|
-
it('does not render zoom controls when disabled', async () => {
|
93
|
-
const el = await fixture(container());
|
94
|
-
|
95
|
-
el.showZoomControls = false;
|
96
|
-
await el.updateComplete;
|
97
|
-
|
98
|
-
expect(el.shadowRoot.querySelector('.zoom_out')).not.to.exist;
|
99
|
-
expect(el.shadowRoot.querySelector('.zoom_in')).not.to.exist;
|
100
|
-
});
|
101
|
-
|
102
|
-
describe('Custom events', () => {
|
103
|
-
it('prepareEventDetails returns proper params', async () => {
|
104
|
-
const el = await fixture(container());
|
105
|
-
await el.updateComplete;
|
106
|
-
const params = el.prepareEventDetails();
|
107
|
-
|
108
|
-
expect(params.activeCount).to.exist;
|
109
|
-
expect(typeof (params.activeCount)).to.be.equal('number');
|
110
|
-
expect(params.changedOptionId).to.exist;
|
111
|
-
expect(typeof (params.changedOptionId)).to.be.equal('string');
|
112
|
-
expect(params.options).to.exist;
|
113
|
-
expect(params.options.length).to.exist;
|
114
|
-
expect(params.options.length).to.be.greaterThan(0);
|
115
|
-
});
|
116
|
-
it('emitOptionChangedEvent calls for the params', async () => {
|
117
|
-
IABookVisualAdjustments.prototype.prepareEventDetails = sinon.fake();
|
118
|
-
const el = await fixture(container());
|
119
|
-
await el.updateComplete;
|
120
|
-
|
121
|
-
expect(el.prepareEventDetails.callCount).to.equal(1);
|
122
|
-
});
|
123
|
-
it('triggers an emitOptionChangedEvent event at firstUpdate', async () => {
|
124
|
-
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
125
|
-
const el = await fixture(container());
|
126
|
-
|
127
|
-
expect(el.emitOptionChangedEvent.callCount).to.equal(1);
|
128
|
-
});
|
129
|
-
|
130
|
-
it('triggers an emitOptionChangedEvent event when a checkbox\'s change event fires', async () => {
|
131
|
-
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
132
|
-
const el = await fixture(container());
|
133
|
-
|
134
|
-
expect(el.emitOptionChangedEvent.callCount).to.equal(1); // firstUpdate fire
|
135
|
-
|
136
|
-
el.shadowRoot.querySelector('li input').dispatchEvent(new Event('change'));
|
137
|
-
expect(el.emitOptionChangedEvent.callCount).to.equal(2);
|
138
|
-
});
|
139
|
-
|
140
|
-
it('triggers an emitOptionChangedEvent event when a range\'s change event fires', async () => {
|
141
|
-
IABookVisualAdjustments.prototype.emitOptionChangedEvent = sinon.fake();
|
142
|
-
|
143
|
-
const el = await fixture(container());
|
144
|
-
expect(el.emitOptionChangedEvent.callCount).to.equal(1); // firstUpdate fire
|
145
|
-
|
146
|
-
el.shadowRoot.querySelector('[name="brightness_range"]').dispatchEvent(new Event('change'));
|
147
|
-
expect(el.emitOptionChangedEvent.callCount).to.equal(2);
|
148
|
-
});
|
149
|
-
|
150
|
-
it('emits a zoom out event when zoom out button clicked', async () => {
|
151
|
-
const el = await fixture(container());
|
152
|
-
|
153
|
-
setTimeout(() => (
|
154
|
-
el.shadowRoot.querySelector('.zoom_out').click()
|
155
|
-
));
|
156
|
-
const response = await oneEvent(el, 'visualAdjustmentZoomOut');
|
157
|
-
|
158
|
-
expect(response).to.exist;
|
159
|
-
});
|
160
|
-
|
161
|
-
it('emits a zoom in event when zoom in button clicked', async () => {
|
162
|
-
const el = await fixture(container());
|
163
|
-
|
164
|
-
setTimeout(() => (
|
165
|
-
el.shadowRoot.querySelector('.zoom_in').click()
|
166
|
-
));
|
167
|
-
const response = await oneEvent(el, 'visualAdjustmentZoomIn');
|
168
|
-
|
169
|
-
expect(response).to.exist;
|
170
|
-
});
|
171
|
-
});
|
172
|
-
|
173
|
-
it('sets range defaults when none supplied', async () => {
|
174
|
-
const el = await fixture(container());
|
175
|
-
const brightnessRange = el.shadowRoot.querySelector('[name="brightness_range"]');
|
176
|
-
|
177
|
-
expect(brightnessRange.getAttribute('min')).to.equal('0');
|
178
|
-
expect(brightnessRange.getAttribute('max')).to.equal('100');
|
179
|
-
expect(brightnessRange.getAttribute('step')).to.equal('1');
|
180
|
-
});
|
181
|
-
|
182
|
-
it('sets the updated range value on the options prop', async () => {
|
183
|
-
const el = await fixture(container());
|
184
|
-
const { id } = options[0];
|
185
|
-
const newValue = 120;
|
186
|
-
|
187
|
-
el.setRangeValue(id, newValue);
|
188
|
-
await el.updateComplete;
|
189
|
-
|
190
|
-
expect(el.options[0].value).to.equal(newValue);
|
191
|
-
});
|
192
|
-
|
193
|
-
it('triggers a setRangeValue event when a range\'s input event fires', async () => {
|
194
|
-
IABookVisualAdjustments.prototype.setRangeValue = sinon.fake();
|
195
|
-
|
196
|
-
const el = await fixture(container());
|
197
|
-
|
198
|
-
el.shadowRoot.querySelector('[name="brightness_range"]').dispatchEvent(new Event('input'));
|
199
|
-
expect(el.setRangeValue.callCount).to.equal(1);
|
200
|
-
});
|
201
|
-
});
|